My first post, as I can't find the answer to this out there.
I have a data bound GridView with a bunch of ComboBoxes. They correctly display the value from the underlying table, and the correct values appear in the drop down lists. 1 of the Comboboxes has an int .valuemember, and everything works great for it. The other ComboBox has string .valuemember, and when I select a different value in the combobox it does not update to the bound table.
They are bound and updated with the same code from the same table and the same grid. I am specifically binding to a ESRI ArcGIS file. It seems to be correctly bound, and I have used it for other projects successfully. It does again display and update changes in all columns, and will accept changes to integer based rows; therefore I have, maybe stupidly, ruled this out.
Not sure what I need to do to make string .valuemember value to update.
I am missing something simple I guess but I don't know what it is. Here is some sample code.
Domain1 As BindingList(Of Domaintype)
Domain2 As BindingList(Of Domaintype)
GridView.DataSource = pBindingSource
'add the columns desired
GridView.Columns.Add(CreateComboBoxColumn("Column1Value", "Type1", Domain1 , "NonCodedIntValue"))
GridView.Columns.Add(CreateComboBoxColumn("Column2Value", "Type2", Domain2 , "NonCodedCharValue"))
Private Function CreateComboBoxColumn(ByVal ColumnName As String, ByVal AliasName As String, ByRef DomainName As BindingList(Of Domaintype), ByVal pValueMember As String) As DataGridViewComboBoxColumn
CreateComboBoxColumn = New DataGridViewComboBoxColumn
With CreateComboBoxColumn
.DataPropertyName = ColumnName
.HeaderText = AliasName
.ReadOnly = False
End With
With CreateComboBoxColumn
.DataSource = DomainName
.DisplayMember = "CodedValue"
.ValueMember = pValueMember
End With
Return CreateComboBoxColumn
End Function
Private Sub GridView_CurrentCellDirtyStateChanged(ByVal sender As Object, ByVal e As EventArgs) Handles GridView.CurrentCellDirtyStateChanged
If GridView.IsCurrentCellDirty Then
GridView.CommitEdit(DataGridViewDataErrorContexts.Commit)
End If
End Sub
Public Class Domaintype
Private CodedValue As String
Private NonCodedInt As Nullable(Of Short)
Private NonCodedChar As String
'adds a new coded value based on a sent non-coded and coded value
Public Sub New(ByVal SentCodedValue As String, ByVal SentNonCoded As Nullable(Of Short), Optional ByVal SentNonCodedChar As String = Nothing)
CodedValue = SentCodedValue
NonCodedInt = SentNonCoded
NonCodedChar = SentNonCodedChar
End Sub
'Gets or sets the coded value of a domain
Public ReadOnly Property CodedValue() As String
Get
Return CodedValue
End Get
End Property
'gets or sets the non-coded value of a domain
Public ReadOnly Property NonCodedIntValue() As Nullable(Of Short)
Get
Return NonCodedInt
End Get
End Property
'gets or sets the non-coded value of a domain
Public ReadOnly Property NonCodedCharValue() As String
Get
Return NonCodedChar
End Get
End Property
End Class