ComboBox bug???

  • Thread starter Thread starter Anthony
  • Start date Start date
A

Anthony

Hello All,

I have a combo-box that contains three items added at design time. When I
try to set the SelectedText property at run-time based on a value from a
SqlDataReader, the SelectedText is not set, but if I step through the code,
the SelectedText gets set. Any help will be greatly appreciated.

Using VB.Net 2003

Thanks,
Anthony
 
Hi,

Try this.

Dim arColor() As String
arColor = KnownColor.GetNames(GetType(KnownColor))
ComboBox1.Items.AddRange(arColor)

ComboBox1.SelectedIndex = ComboBox1.FindString("Blue")


Ken
--------------------
 
Is there any difference between these two statements?

ComboBox1.SelectedIndex = ComboBox1.FindString("Blue")

vs

ComboBox1.Text = "Blue"

They both appear to set the SelectedIndex (if Blue weren't in the list both
will set it to -1).

Just curious.

Greg
 
Hi,

FindString finds an item in the combobox that starts with those
letters. For example combobox1.text = "blu" makes selectionindex=-1
combobox1.findstring("blu") comes up with blue.

Ken
 
Even though that solution worked I am curious as to why just stepping
through the debugger without changing any code caused it to work.
I am having a similair problem but with a listbox in an ASP.NET
page. On the click of a button items are being added to the listbox which
do not show up unless I put a break point in the code and sort of give
it time to show up it seems. It seems if the pause is about 1 second or
greater
it shows up otherwise it does not. Same as Anthony's problem.

Kenny.
 
Back
Top