How To Update A Janus GridEx Checkbox At Runtime

1.2k Views Asked by At

I have a Janus GridEx control named grdLOB that can have multiple rows. Each row has a checkbox and 3 additional columns. If a checkbox is unchecked on a certain row (GL) I need to loop thru the grid and uncheck the checkboxes in the other rows.

Here is the code I have, but obviously it's not working...

Private Sub grdLOB_CellValueChanged(ByVal sender As Object, ByVal e as Janus.Windows.GridEX.ColumnActionEventArgs) Handles grdLOB.CellValueChanged

    If e.Column.Key = cSelector Then
        Dim grd As Janus.Windows.GridEX.GridEX = CType(sender, GridEX)
        Dim row As GridEXRow = grd.GetRow(grd.Row)

        Select Case row.Cells(1).Value.ToString().ToUpper()
            Case "GL"
                'If GL is checked, do nothing to the other rows.
                'If GL is unchecked, uncheck all the other rows.
                If CBool(row.Cells(0).Value) = False Then
                    For Each gr As GridEXRow In grdLOB.GetRows()
                        gr.BeginEdit()
                        gr.Cells(0).Value = False
                        gr.EndEdit()
                    Next
                End If
            Case Else
                'If a row other than GL is unchecked, do nothing to the other rows.
                'If a row other than GL is checked, then check the GL row.
                If CBool(row.Cells(0).Value) = True Then
                    For Each gr As GridEXRow In grdLOB.GetRows()
                        If gr.Cells(1).Value = "GL" Then
                            gr.BeginEdit()
                            gr.Cells(0).Value = True
                            gr.EndEdit()
                        End If
                    Next
                End If
        End Select
    End If

End Sub

How can I dynamically check\uncheck checkboxes in the GridEx?

1

There are 1 best solutions below

0
On

Figured it out. Here's the changed Select Case code that works:

Select Case row.Cells(1).Value.ToString().ToUpper()
            Case "GL"
                'If GL is checked, do nothing to the other rows.
                'If GL is unchecked, uncheck all the other rows.
                If CBool(row.Cells(0).Value) = False Then
                    For i As Integer = 0 To grdLOB.RowCount - 1
                        Dim gr As GridEXRow = grdLOB.GetRow(i)
                        gr.IsChecked = False
                    Next
                End If
            Case Else
                'If a row other than GL is unchecked, do nothing to the other rows.
                'If a row other than GL is checked, then check the GL row.
                If CBool(row.Cells(0).Value) = True Then
                    For i As Integer = 0 To grdLOB.RowCount - 1
                        Dim gr As GridEXRow = grdLOB.GetRow(i)
                        If gr.Cells(1).Value = "GL" Then
                            gr.IsChecked = True
                        End If
                    Next
                End If
        End Select