Combox Problem setting a value

  • Thread starter Thread starter Justin Champion
  • Start date Start date
J

Justin Champion

Hello can anyone assist with this problem with a combobox, or point to a
website which disucsses it. I have set a number of options in a combox say
the a list of names I then want when a person click a button for a value to
be selected via its string name.

So I added
items.add("Justin")
items.add("Adrian")
items.add("John")

so when I click the buton the name John is slected. I can not find a way of
doing this at the mment. !!!!


Thanks in advance,


Justin.
 
Hi,
it when the button is clicked you set strMyVar to the value required (e.g.
Adrian) then

For Ict = 1 To cmbUserName.Items.Count
If cmbUserName.Items(Ict).ToString = strMyVar Then
cmbUserName.SelectedIndex = Ict
Exit For
End If
Next

will select it in the combo box

Pete
--
Pete Vickers
Microsoft Windows Embedded MVP
HP Business Partner
http://www.gui-innovations.com

Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups? Let us know!
https://www.windowsembeddedeval.com/community/newsgroups
 
thank you for the solution.

Justin.

--
----------------------------------------------------------------------------
--------
"There's no point in being grown up if you can't be childish sometimes"
Fourth Doctor Who(Tom Baker)
Doctor Who Web Site www.doctorwho.hopto.org
 
One more way to do this.( I think in case u set the datasource u may have to
do this)

for (intIndex = 0;intIndex < cmbComboBox.Items.Count; intIndex++)
{
if (cmbComboBox.GetItemText(cmbComboBox.Items[intIndex]) == strVal)
{
cmbComboBox.SelectedIndex = intIndex;
break;
}
}
 
Back
Top