Specifies a column in which each cell contains a check box for representing a boolean value.
Object
Component
DataGridColumn
DataGridBoolColumn
[Visual Basic] Public Class DataGridBoolColumn Inherits DataGridColumn [C#] public class DataGridBoolColumn : DataGridColumn [C++] public __gc class DataGridBoolColumn : public DataGridColumn [JScript] public class DataGridBoolColumn extends DataGridColumn
The DataGridBoolColumn derives from the abstract (in Visual Basic MustInherit) class DataGridColumn. At run time, the DataGridBoolColumn contains check boxes in each cell that have have three states: checked (true), unchecked (false), and indeterminate (a null reference (in Visual Basic Nothing)).
Properties added to the class include FalseValue, NullValue, and TrueValue. These properties determine the applicable value for each of the column's states.
DataGridBoolColumn is a derived class and overrides the following methods: GetPreferredHeight, GetPreferredSize, GetMinimumHeight, Abort, Commit, Edit, KeyPress, and Paint.
If you are creating a new DataGridBoolColumn, you must associate it with a DataColumn--either one that exists or a new one--before adding it to the GridColumnsCollection collection through the Add method. To do this, set the System.WinForms.DataGridColumn.DataColumn property to the desired DataColumn object.
The DataType property of the DataType should be set to type boolean using the Type class's GetType method, as shown in the example following remarks.
CAUTION Once you associate a DataGridBoolColumn with a DataColumn, attempting to reset the System.WinForms.DataGridColumn.DataColumn property can produce unpredictable results.
Namespace: System.WinForms
Assembly: System.WinForms.dll
The following example first creates a DataColumn that is then added to the DataTable. A new DataGridBoolColumn is then created and the object's System.WinForms.DataGridColumn.DataColumn property is set to the new DataColumn object. Finally, the DataGridBoolColumn is added to the GridColumnsCollection collection.
[Visual Basic]
Private Sub MakeBoolCol() Dim dc As New DataColumn Set dc.DataType = [Type].GetType("System.Boolean") dc.ColumnName = "myBoolColumn" dc.Caption = "True or False" ' Presuming a DataGrid control exists, add the DataColumn. dc.DefaultValue = False DataGrid1.CurrentGridTable.DataTable.Columns.Add dc ' Create the New DataGridBoolColumn, associating it with the DataColumn. Dim dbCol As DataGridBoolColumn Set dbcol = New DataGridBoolColumn(dc) ' Add the column to the DataGridsColumn collection. DataGrid1.GridColumns.Add dbCol End Sub
DataGridBoolColumn Members | System.WinForms Namespace | Add | DataColumn | DataGrid | DataGridColumn | GridColumnsCollection | GetType | Type