Posted 1 August 2019, 6:05 pm EST
Hello,
I am trying to use C1FlexGrid with a MultiColumnDictionary DataMap that changes based on value in previous column.
When I change the value cols(“AcType”) the datamap for the next column cols(“SubAc”) changes to the corresponding set of values. However when I move to another row that has a different value in cols(“AcType”) and thus a different datamap for cols(“SubAc”) and I click the dropdown, the SubAc values in the other rows go blank, I guess because the key value is not in the list anymore.
Can C1FlexGrid and datamap be used like this?
Is there another way (different controls) to get this kind of thing to work?
Thank you
Brian
My code is …
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim dtAcType As New DataTable
Dim da1 As New SqlDataAdapter(“SELECT AcType, AcTypeName FROM dbo.fntvGetAcTypesList(NULL, NULL) WHERE AcType IN (0, 1, 2, 4, 5);”, DbConnection)
da1.Fill(dtAcType)
Dim dtSubAc As New DataTable
Dim da2 As New SqlDataAdapter(“SELECT SubAc, ShortTypeName FROM dbo.fntvGetAcTypesList(NULL, NULL) WHERE AcType = 0”, DbConnection)
da2.Fill(dtSubAc)
With Me.C1FlexGrid1
.Cols(1).Name = “ID”
.Cols(2).Name = “AcType”
.Cols(3).Name = “SubAc”
.Cols(4).Name = “TranDate”
.Cols(“AcType”).DataMap = New MultiColumnDictionary(dtAcType, “AcType”, {“AcType”, “AcTypeName”}, 0)
.Cols(“SubAc”).DataMap = New MultiColumnDictionary(dtSubAc, “SubAc”, {“SubAc”, “ShortTypeName”}, 0)
End With
End Sub
Private Sub C1FlexGrid1_StartEdit(sender As Object, e As RowColEventArgs) Handles C1FlexGrid1.StartEdit
If Me.C1FlexGrid1.Cols(e.Col).Name = “SubAc” Then
If Not Me.C1FlexGrid1(e.Row, “AcType”) Is Nothing Then
Dim da2 As New SqlDataAdapter("SELECT SubAc, ShortTypeName FROM dbo.fntvGetAcTypesList(NULL, NULL) WHERE AcType = " & Me.C1FlexGrid1(e.Row, “AcType”), DbConnection)
Dim dtSubAc As New DataTable
da2.Fill(dtSubAc)
Me.C1FlexGrid1.Cols(“SubAc”).DataMap = New MultiColumnDictionary(dtSubAc, “SubAc”, {“SubAc”, “ShortTypeName”}, 0)
End If
End If
End Sub