DataGridBoolColumn Constructors
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the DataGridBoolColumn class.
Overloads
DataGridBoolColumn() |
Initializes a new instance of the DataGridBoolColumn class. |
DataGridBoolColumn(PropertyDescriptor) |
Initializes a new instance of the DataGridBoolColumn class with the specified PropertyDescriptor. |
DataGridBoolColumn(PropertyDescriptor, Boolean) |
Initializes a new instance of the DataGridBoolColumn class with the specified PropertyDescriptor, and specifying whether the column style is a default column. |
DataGridBoolColumn()
Initializes a new instance of the DataGridBoolColumn class.
public:
DataGridBoolColumn();
public DataGridBoolColumn ();
Public Sub New ()
Examples
The following code example first creates a new DataGridBoolColumn and adds it to the GridColumnStylesCollection of a DataGridTableStyle.
void AddDataGridBoolColumnStyle()
{
DataGridBoolColumn^ myColumn = gcnew DataGridBoolColumn;
myColumn->MappingName = "Current";
myColumn->Width = 200;
dataGrid1->TableStyles[ "Customers" ]->GridColumnStyles->Add( myColumn );
}
private void AddDataGridBoolColumnStyle(){
DataGridBoolColumn myColumn = new DataGridBoolColumn();
myColumn.MappingName = "Current";
myColumn.Width = 200;
dataGrid1.TableStyles["Customers"].GridColumnStyles.Add(myColumn);
}
Private Sub AddDataGridBoolColumnStyle()
Dim myColumn As DataGridBoolColumn = new DataGridBoolColumn()
myColumn.MappingName = "Current"
myColumn.Width = 200
dataGrid1.TableStyles("Customers").GridColumnStyles.Add(myColumn)
End Sub
Remarks
When using this overload to create a DataGridBoolColumn, be sure to set the MappingName value to the ColumnName of a DataColumn.
See also
Applies to
DataGridBoolColumn(PropertyDescriptor)
Initializes a new instance of the DataGridBoolColumn class with the specified PropertyDescriptor.
public:
DataGridBoolColumn(System::ComponentModel::PropertyDescriptor ^ prop);
public DataGridBoolColumn (System.ComponentModel.PropertyDescriptor prop);
new System.Windows.Forms.DataGridBoolColumn : System.ComponentModel.PropertyDescriptor -> System.Windows.Forms.DataGridBoolColumn
Public Sub New (prop As PropertyDescriptor)
Parameters
- prop
- PropertyDescriptor
The PropertyDescriptor associated with the column.
Examples
The following code example uses the GetItemProperties method to return a System.ComponentModel.PropertyDescriptorCollection for a DataTable. The PropertyDescriptor for a DataColumn is then used to create the DataGridBoolColumn.
void CreateNewDataGridColumn()
{
System::Windows::Forms::GridColumnStylesCollection^ myGridColumnCol;
myGridColumnCol = dataGrid1->TableStyles[ 0 ]->GridColumnStyles;
// Get the CurrencyManager for the table.
CurrencyManager^ myCurrencyManager = dynamic_cast<CurrencyManager^>(this->BindingContext[ ds->Tables[ "Products" ] ]);
/* Get the PropertyDescriptor for the DataColumn of the new column.
The column should contain a Boolean value. */
PropertyDescriptor^ pd = myCurrencyManager->GetItemProperties()[ "Discontinued" ];
DataGridColumnStyle^ myColumn = gcnew System::Windows::Forms::DataGridBoolColumn( pd );
myColumn->MappingName = "Discontinued";
myGridColumnCol->Add( myColumn );
}
private void CreateNewDataGridColumn(){
System.Windows.Forms.GridColumnStylesCollection myGridColumnCol;
myGridColumnCol = dataGrid1.TableStyles[0].GridColumnStyles;
// Get the CurrencyManager for the table.
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext[ds.Tables["Products"]];
/* Get the PropertyDescriptor for the DataColumn of the new column.
The column should contain a Boolean value. */
PropertyDescriptor pd = myCurrencyManager.
GetItemProperties()["Discontinued"];
DataGridColumnStyle myColumn =
new System.Windows.Forms.DataGridBoolColumn(pd);
myColumn.MappingName = "Discontinued";
myGridColumnCol.Add(myColumn);
}
Private Sub CreateNewDataGridColumn()
Dim myGridColumnCol As GridColumnStylesCollection
myGridColumnCol = dataGrid1.TableStyles(0).GridColumnStyles
' Get the CurrencyManager for the table.
Dim myCurrencyManager As CurrencyManager = _
CType(Me.BindingContext(ds.Tables("Products")), CurrencyManager)
' Get the PropertyDescriptor for the DataColumn of the new column.
' The column should contain a Boolean value.
Dim pd As PropertyDescriptor = _
myCurrencyManager.GetItemProperties()("Discontinued")
Dim myColumn As New DataGridBoolColumn(pd)
myColumn.MappingName = "Discontinued"
myGridColumnCol.Add(myColumn)
End Sub
Remarks
The DataGridBoolColumn must be associated with a data source that contains Boolean values.
To get a PropertyDescriptor, first use the BindingContext to return the appropriate BindingManagerBase. Then use the GetItemProperties method of the BindingManagerBase to return a PropertyDescriptorCollection. Finally, use the Item[] property of the PropertyDescriptorCollection to return the specific PropertyDescriptor for the column.
See also
Applies to
DataGridBoolColumn(PropertyDescriptor, Boolean)
Initializes a new instance of the DataGridBoolColumn class with the specified PropertyDescriptor, and specifying whether the column style is a default column.
public:
DataGridBoolColumn(System::ComponentModel::PropertyDescriptor ^ prop, bool isDefault);
public DataGridBoolColumn (System.ComponentModel.PropertyDescriptor prop, bool isDefault);
new System.Windows.Forms.DataGridBoolColumn : System.ComponentModel.PropertyDescriptor * bool -> System.Windows.Forms.DataGridBoolColumn
Public Sub New (prop As PropertyDescriptor, isDefault As Boolean)
Parameters
- prop
- PropertyDescriptor
The PropertyDescriptor associated with the column.
- isDefault
- Boolean
true
to specify the column as the default; otherwise, false
.
Remarks
To get a PropertyDescriptor, first use the BindingContext to return the appropriate BindingManagerBase. Then use the GetItemProperties method of the BindingManagerBase to return a PropertyDescriptorCollection. Finally, use the Item[] property of the PropertyDescriptorCollection to return the specific PropertyDescriptor for the column.