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

CheckBox column click

I have a datagrid in my column that has one DataGridBoolColumn (check box) and several text columns. I created bool column with a following code: Dim Col As New DataGridBoolColumn() Col.HeaderText = "Select" Col.MappingName = "Select" Col.AllowNull = False Col.TrueValue = True Col.FalseValue = False tableStyle.GridColumnStyles.Add(unboundColStyle) After this I have a column with a check box. Now I'd like to get rid of this DBNull value that comes when I click the check box. I added this code to the mouseDown event in the grid: Dim hti As DataGrid.HitTestInfo = Me.dgr.HitTest(e.X, e.Y) Try If hti.Type = DataGrid.HitTestType.Cell AndAlso hti.Column = 0 Then Me.dgr(hti.Row, hti.Column) = Not CBool(dgr(hti.Row, hti.Column)) End If Catch ex As Exception MessageBox.Show(ex.ToString()) End Try This code crashes because checkbox has a value DBNull. So, how to get rid of this DBNull value? And does anyone know why the check box is disabled(gray) at the beginning?

1 Reply

AD Administrator Syncfusion Team March 26, 2003 03:13 PM UTC

The grey box means the value is NULL. > I have a datagrid in my column that has one DataGridBoolColumn (check box) and several text columns. I created bool column with a following code: > > Dim Col As New DataGridBoolColumn() > > Col.HeaderText = "Select" > Col.MappingName = "Select" > > Col.AllowNull = False > > Col.TrueValue = True > Col.FalseValue = False > > tableStyle.GridColumnStyles.Add(unboundColStyle) > > After this I have a column with a check box. Now I'd like to get rid of this DBNull value that comes when I click the check box. I added this code to the mouseDown event in the grid: > > > Dim hti As DataGrid.HitTestInfo = Me.dgr.HitTest(e.X, e.Y) > > Try > > If hti.Type = DataGrid.HitTestType.Cell AndAlso hti.Column = 0 Then > > Me.dgr(hti.Row, hti.Column) = Not CBool(dgr(hti.Row, hti.Column)) > > End If > > Catch ex As Exception > MessageBox.Show(ex.ToString()) > End Try > > This code crashes because checkbox has a value DBNull. So, how to get rid of this DBNull value? And does anyone know why the check box is disabled(gray) at the beginning?

Loader.
Up arrow icon