Freigeben über


DataGridBoolColumn-Konstruktor (PropertyDescriptor)

Initialisiert eine neue Instanz einer DataGridBoolColumn mit dem angegebenen PropertyDescriptor.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Sub New ( _
    prop As PropertyDescriptor _
)
'Usage
Dim prop As PropertyDescriptor

Dim instance As New DataGridBoolColumn(prop)
public DataGridBoolColumn (
    PropertyDescriptor prop
)
public:
DataGridBoolColumn (
    PropertyDescriptor^ prop
)
public DataGridBoolColumn (
    PropertyDescriptor prop
)
public function DataGridBoolColumn (
    prop : PropertyDescriptor
)

Parameter

Hinweise

DataGridBoolColumn muss einer Datenquelle zugeordnet sein, die Boolean-Werte enthält.

Verwenden Sie zum Abrufen eines PropertyDescriptor zunächst BindingContext, um die entsprechende BindingManagerBase zurückzugeben. Verwenden Sie dann die GetItemProperties-Methode von BindingManagerBase, um eine PropertyDescriptorCollection zurückzugeben. Abschließend verwenden Sie die Item-Eigenschaft von PropertyDescriptorCollection, um den für die Spalte spezifischen PropertyDescriptor zurückzugeben.

Beispiel

Im folgenden Codebeispiel wird mithilfe der GetItemProperties-Methode eine System.ComponentModel.PropertyDescriptorCollection für eine DataTable zurückgegeben. Dann wird der PropertyDescriptor für eine DataColumn zum Erstellen von DataGridBoolColumn verwendet.

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 
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);
}
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.get_TableStyles().
        get_Item(0).get_GridColumnStyles();
    // Get the CurrencyManager for the table.
    CurrencyManager myCurrencyManager = 
        (CurrencyManager)(this.get_BindingContext().
        get_Item(ds.get_Tables().get_Item("Products")));
    /*  Get the PropertyDescriptor for the DataColumn of the new column.
        The column should contain a Boolean value. 
     */
    PropertyDescriptor pd = myCurrencyManager.GetItemProperties().
        get_Item("Discontinued");
    DataGridColumnStyle myColumn = 
        new System.Windows.Forms.DataGridBoolColumn(pd);        
    myColumn.set_MappingName("Discontinued");
    myGridColumnCol.Add(myColumn);
} //CreateNewDataGridColumn

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

DataGridBoolColumn-Klasse
DataGridBoolColumn-Member
System.Windows.Forms-Namespace
DataGrid-Klasse
DataGridColumnStyle
GridColumnStylesCollection
DataColumn