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.

2replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • 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"};

    Like 1
    • Ken Wyant Thank you! Exactly what I was looking for and worked fine.

print this pagePrint this page
Like1 Follow
  • Status Answered
  • 5 mths agoLast active
  • 2Replies
  • 33Views
  • 2 Following