I have a very weird issue. I have a ComboBox control on a form. It has a DataSource of DataTable. It has both DisplayMember and ValueMember set. I have debugged and set break points, the very last bit of code confirms that the data IS THERE. I have used the DataTable visualizer and rows are displayed with the values I want. I have run commands in the Immediate window while debugging to check the count of items, confirm the DisplayMember etc all is okay there. The empty white space that appears in the ComboBox changes size as per my selection, but no text is displayed? Very very strange. I have set up another ComboBox in exactly the same way and it works fine. IT SHOULD WORK! The back end tells me that it is working, but it just simply isn't displaying. Any ideas? .NET 4, VB.NET, WinForms. Anyone have this issue/solution?
Here's the code (it never errors either).
Public Sub RefreshContacts(ByVal CustomerKey As Integer)
Using tContactsTa As New dbQMSTableAdapters.tContactsTableAdapter, tContactsDt As New dbQMS.tContactsDataTable
Try
tContactsTa.FillBasicByCustomerKey(tContactsDt, CustomerKey)
cmbCncts.BeginUpdate()
With cmbCncts
.DataSource = tContactsDt
.ValueMember = "fContactKey"
.DisplayMember = "fContactName"
End With
cmbCncts.EndUpdate()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
End Try
End Using
End Sub
As I said before, I have debugged and looked at the DataTable visualiser, the data is there. When I run ? cmbCncts.Items.Count
it feedsback the correct value. I also check the DisplayMember
and the ValueMember
properties which are all correct.
datamode
property of combobox set tonormal
? – akhil kumarDataMode
property. There isDrawMode
and yes it is set toNormal
– Billy Brownusing
part. put it outside – programer Anel