TestComplete UserForms - TcxListBox issue
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017
12:18 PM
12-07-2017
12:18 PM
TestComplete UserForms - TcxListBox issue
Hello,
I have a listBox and need to select all the rows in the list after a checkbox is checked.
This is the piece of code that I'm using. I'm running into an issue at the line marked in bold. I've attached the snapshot of error as well. any help would be appreciated!
function UsrForm_cxCheckBoxAllFunctions_OnChange(Sender) { if(UserForms.UsrForm.cxCheckBoxAllFunctions.Checked){ Log.Message("List Length is: " +UserForms.UsrForm.cxListAllFunctions.Items.Count); for(var i = 0; i< UserForms.UsrForm.cxListAllFunctions.Items.Count; i++){ Log.Message("UserForms.UsrForm.cxListAllFunctions.Selected("+i+") = " + UserForms.UsrForm.cxListAllFunctions.Selected(i)); UserForms.UsrForm.cxListAllFunctions.Selected(i) = true; } }else{ for(var i = 0; i< UserForms.UsrForm.cxListAllFunctions.Items.Count; i++){ UserForms.UsrForm.cxListAllFunctions.Selected(i) == false; } } }
Thank you
Abhi
Solved! Go to Solution.
3 REPLIES 3
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017
04:05 PM
12-07-2017
04:05 PM
What output do you get from that Log.Message right above where your error occurs?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2017
12:39 AM
12-08-2017
12:39 AM
Hi Abhi,
JavaScript (not to be confused with JScript) does not support direct assignment to parameterized properties.
UserForms.UsrForm.cxListAllFunctions.Selected(i) = true;
You need to use the $set method instead:
UserForms.UsrForm.cxListAllFunctions.$set("Selected", i, true);
JavaScript Specifics - Indexed Properties
By the way, you can make this code a bit simpler by using variables:
function UsrForm_cxCheckBoxAllFunctions_OnChange(Sender) { var form = UserForms.UsrForm; var listBox = form.cxListAllFunctions; var state = form.cxCheckBoxAllFunctions.Checked; Log.Message("List Length is: " + listBox.Items.Count); for (var i = 0; i < listBox.Items.Count; i++) { listBox.$set("Selected", i, state); } }
Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2017
07:40 AM
12-08-2017
07:40 AM
Thank you, Helen! This is fantastic.
Thank you
Abhi
