How to set a list box to a certain selected item
Let's say I have a list box (ListBox1) with 2 values (Test1 and Test2) with multi-select off. It is currently showing "Test2". I know how to know what it is set to and use that elsewhere in scripting. What I haven't figured out though is how to set that list box to another value in the script. Let's say I want a button that will set that list box mentioned above to the value of "Test1". How could I do this? I think an example of the script for that simple thing would help me with things where I might need to do something like this.
2 replies
-
Hey James. Here is a quick example that I hope gets you going in the right direction.
public void Thing1_OnClick(object sender, EventArgs eventArgs)
{
ListBox1.SelectedItems = new string[] {"Pick thing 1"};
}
public void Thing2_OnClick(object sender, EventArgs eventArgs)
{
ListBox1.SelectedItems = new string[] {"Pick thing 2"};
}
Content aside
Print this page- Status Answered
-
1
Likes
- 9 mths agoLast active
- 2Replies
- 40Views
-
2
Following