Hi,
I'm using a databound DataGridViewComboBoxColumn and I'd like to have a displaymember with is different from the value.
The solution I've thought about is:
The problem is that when I'm using only displaymember looks like everything is OK, but when I'm adding the value member to the column I get the error message:
"datagridviewcomboboxcell value is not valid" immediately when I'm leaving the cell on the datagridview.
Any help will be appreciated.
Thanks
Ihab
I'm using a databound DataGridViewComboBoxColumn and I'd like to have a displaymember with is different from the value.
The solution I've thought about is:
VB.NET:
Public Shared Sub OnComboBoxPopulate(ByVal p_tableName As String, ByVal p_MemberName As String, _
ByVal p_ds As DataSet, Optional ByVal p_col As DataGridViewComboBoxColumn = Nothing)
Dim dt As DataTable = New DataTable
dt = p_ds.Tables(p_tableName)
With p_col
If dt IsNot Nothing Then
'.Name = p_col.Name
.DataSource = dt
.ValueMember = "id"
.DisplayMember = p_MemberName
.DataPropertyName = "id"
End If
End With
End Sub
The problem is that when I'm using only displaymember looks like everything is OK, but when I'm adding the value member to the column I get the error message:
"datagridviewcomboboxcell value is not valid" immediately when I'm leaving the cell on the datagridview.
Any help will be appreciated.
Thanks
Ihab