ComboBox first entry text is displayed,but SelectedIndex = -1

S

Scott M

I have combo boxes that use DataTables as the data source and while they
load just fine but the problem is that the text for the first entry in the
list is always displayed in every combo box (when it should be blank), even
though I set the SelectedIndex to -1. I cannot seem to find any way to stop
this. Any ideas?

Private Sub SetCustomersCombo()
m_Processing = True
' Sets the Data Table object associated with this Combo Box
With Me.cboSelectCustomer
.BeginUpdate()
.DataSource = m_DTCustomers
.DisplayMember = "Display"
.ValueMember = "ID"
.EndUpdate()
.SelectedIndex = -1
End With
m_Processing = False
End Sub

...snippet of code that loads the DataTable object

ItemIndex = 0
With m_DTCustomers
.Clear()
.Columns.Add(New DataColumn("ID", GetType(Integer)))
.Columns.Add(New DataColumn("Display", GetType(String)))
Do While MyDataReader.Read
.Rows.Add(.NewRow())
.Rows(ItemIndex)(0) = MyDataReader.GetInt32(0)
.Rows(ItemIndex)(1) = MyDataReader.GetString(1)
ItemIndex += 1
Loop
End With
 
H

Herfried K. Wagner [MVP]

Hello,

Scott M said:
I have combo boxes that use DataTables as the data
source and while they load just fine but the problem is that the
text for the first entry in the list is always displayed in every
combo box (when it should be blank), even though I
set the SelectedIndex to -1. I cannot seem to find any
way to stop this. Any ideas?

BUG: ComboBox Does Not Clear When You Set SelectedIndex to -1
http://support.microsoft.com/?id=327244

HTH,
Herfried K. Wagner
 
S

Scott M

Thanks. FYI - the bug continues through Framework version 1.1.4322, not just
1.0.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top