I have a combobox on a WinForm.
I can assign an entire array to the Items collection and have it display in
the drop down list.
But how to I make a particular item the selected item (i.e., the one that is
displayed in the combobox on Form.Load)?
I can hard code a value with
comboBox1.Text="X";
But I want to do somthing like:
comboBox1.SelectedItem=1;
Where 1 is the position in the array of the selected item.
"Dave" <davefrick@newsgroup.nospam> schrieb:
> But how to I make a particular item the selected item (i.e., the one that
> is displayed in the combobox on Form.Load)?
[quoted text clipped - 6 lines]
>
> Where 1 is the position in the array of the selected item.
\\\
With Me.ListBox1
.Items.AddRange(New String() {"Item1", "Item2", "Item3"})
.SelectedIndex = 2
End With
///

Signature
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/
Peter Jausovec - 12 Dec 2004 19:57 GMT
or in C# :) :
listBox1.Items.AddRange (new string [] {"Item1", "Item2", "Item3"});
listBox1.SelectedIndex = 2;

Signature
Regards,
Peter Jausovec
(http://blog.jausovec.net)
> "Dave" <davefrick@newsgroup.nospam> schrieb:
>> But how to I make a particular item the selected item (i.e., the one that
[quoted text clipped - 14 lines]
> End With
> ///
Herfried K. Wagner [MVP] - 12 Dec 2004 20:28 GMT
"Peter Jausovec" <peter@jausovec.net> schrieb:
> or in C# :) :
Ooops. I missed that ;-)...

Signature
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/