We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

GDBG Checkbox interaction

I have a GridDataBound grid where rows are paired, I need to have a blank line between each pair of rows and checkboxes to select only one row from each pair. I have code in place to uncheck the other checkbox in a pair when one is checked, but somehow it will also uncheck all other checkboxes in the grid. I have noticed that if I check a box then give focus to a couple non-checkbox cells before checking another checkbox in a different pair then it will behave as intended. I''ve attached a Sample Project that illustrates this issue. Thanks

2 Replies

AD Administrator Syncfusion Team May 23, 2005 03:29 PM UTC

Thank you for your sample. To make sure the changes you are directly setting in the checkboxclick event are saved, try setting the grid.Binder.DirectSaveCellInfo property while you make the change.
Private Sub _grid_CheckBoxClick(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridCellClickEventArgs) Handles _grid.CheckBoxClick
        Dim modulo As Integer
        Dim newCheckValue As Boolean
        ''Check box does not reflect change from click yet, so we have to invert it''s value
        newCheckValue = Not CBool(_grid(e.RowIndex, e.ColIndex).CellValue)
        Me._grid.Binder.DirectSaveCellInfo = True
        ''checkboxes are always in pairs, when one is checked, it''s counterpart must be unchecked.
        If newCheckValue Then
            modulo = e.RowIndex Mod 3 ''Each set of data series is 3 rows, Actual, Trend and Blank
            Select Case modulo
                Case 2
                    ''This is the trend line. Line above must be false
                    _grid(e.RowIndex - 1, e.ColIndex).CellValue = False
                Case 1
                    ''This is the actual data series.  Line below must be false
                    _grid(e.RowIndex + 1, e.ColIndex).CellValue = False
            End Select
        End If
        Me._grid.Binder.DirectSaveCellInfo = False
    End Sub

            


AD Administrator Syncfusion Team May 23, 2005 03:47 PM UTC

Thanks! That worked great.

Loader.
Live Chat Icon For mobile
Up arrow icon