DataGridViewComboBoxColumn value is not updated (integers)

My first post, since I can not find the answer to this question.

I have a data-bound GridView with a bunch of ComboBoxes. They correctly display the value from the base table, and the correct values โ€‹โ€‹are displayed in the drop-down lists. 1 of Comboboxes has an int.valuemember, and everything works fine for it. Another ComboBox has a .valuemember row, and when I select a different value in combobox, it is not updated in the linked table.

They are tied and updated with the same code from the same table and the same grid. I specifically bind to an ArcGIS ESRI file. This seems to be correctly connected, and I have successfully used it for other projects. It displays and updates changes in all columns again and accepts changes in rows based on integers; so I, maybe stupidly, decided that.

Not sure what I need to do so that the value of the .valuemember string is updated.

I miss something simple, I think, but I donโ€™t know what it is. Here is a 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 
+4
source share

Source: https://habr.com/ru/post/1441924/


All Articles