I am currently having issues with a databound combobox, which I am trying to display as a drop down list.
I thought I had it sorted, but no.
This is my code
setupFeescbx is called when the form initially loads and then again if the list of categories is changed (when I want to repopulate the available options).
The selecteditem property of the combobox is bound in its properties table to EntrantBindingSource -feecategory.
The idea is that the combo box displays the value from the EntrantBindingSource, which must also be one of the available options from the "entryfees" table. It seems to work at first sight, as I move forward through the records, but when I go backwards, the text on the combobox changes to "System.Data.Datarowview". Looking at the options in the combobox, there is a list equal in length to the number of records in my dataset, rather than the number of fee categories.
Clearly I am doing something terribly wrong, but I would appreciate being pointed in the right direction please. I realise that even if I do get it working as intended, I will have to somehow handle a category being removed from the list, as presumably that would cause issues if I try to display a record with a value that is no longer available on the drop down list...in my mind, it would revert to a default value that is always in the list.
Thanks for reading!
I thought I had it sorted, but no.
This is my code
VB.NET:
Private Sub setupFeescbx()
EntrantBindingSource.RaiseListChangedEvents = False
With FeecategoryComboBox
For Each row As DataRow In dsEDX.Tables("entryfees").Rows
If Not (.Items.Contains(row.Item("category").ToString)) Then
.Items.Add(row.Item("category").ToString)
End If
Next
EntrantBindingSource.RaiseListChangedEvents = True
.DataSource = EntrantBindingSource
.DisplayMember = "feecategory"
End With
End Sub
setupFeescbx is called when the form initially loads and then again if the list of categories is changed (when I want to repopulate the available options).
The selecteditem property of the combobox is bound in its properties table to EntrantBindingSource -feecategory.
The idea is that the combo box displays the value from the EntrantBindingSource, which must also be one of the available options from the "entryfees" table. It seems to work at first sight, as I move forward through the records, but when I go backwards, the text on the combobox changes to "System.Data.Datarowview". Looking at the options in the combobox, there is a list equal in length to the number of records in my dataset, rather than the number of fee categories.
Clearly I am doing something terribly wrong, but I would appreciate being pointed in the right direction please. I realise that even if I do get it working as intended, I will have to somehow handle a category being removed from the list, as presumably that would cause issues if I try to display a record with a value that is no longer available on the drop down list...in my mind, it would revert to a default value that is always in the list.
Thanks for reading!