Freigeben über


DataGridColumnStyle.PropertyDescriptor-Eigenschaft

Ruft den PropertyDescriptor ab, der die Attribute der Daten ermittelt, die vom DataGridColumnStyle angezeigt werden, oder legt diesen fest.

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

Syntax

'Declaration
Public Overridable Property PropertyDescriptor As PropertyDescriptor
'Usage
Dim instance As DataGridColumnStyle
Dim value As PropertyDescriptor

value = instance.PropertyDescriptor

instance.PropertyDescriptor = value
public virtual PropertyDescriptor PropertyDescriptor { get; set; }
public:
virtual property PropertyDescriptor^ PropertyDescriptor {
    PropertyDescriptor^ get ();
    void set (PropertyDescriptor^ value);
}
/** @property */
public PropertyDescriptor get_PropertyDescriptor ()

/** @property */
public void set_PropertyDescriptor (PropertyDescriptor value)
public function get PropertyDescriptor () : PropertyDescriptor

public function set PropertyDescriptor (value : PropertyDescriptor)

Eigenschaftenwert

Ein PropertyDescriptor, der Daten über die Attribute der Spalte enthält.

Hinweise

Der PropertyDescriptor für eine Spalte wird mithilfe der GetItemProperties-Methode der BindingManagerBase festgelegt. Ein Beispiel für die Verwendung von PropertyDescriptor zum Erstellen eines neuen DataGridColumnStyle finden Sie unter dem DataGridColumnStyle-Konstruktor.

Beispiel

Im folgenden Codebeispiel wird der PropertyDescriptor einer Spalte in einer GridColumnStylesCollection abgerufen. Im zweiten Beispiel wird mit einem PropertyDescriptor ein neuer DataGridColumnStyle erstellt.

Private Sub GetPropertyDescriptor()
    Dim pd As PropertyDescriptor
    pd = dataGrid1.TableStyles(0).GridColumnStyles(0).PropertyDescriptor
    Console.WriteLine(pd.ToString())
End Sub 'GetPropertyDescriptor


Private Sub CreateNewDataGridColumnStyle()
    Dim myGridColumnCol As GridColumnStylesCollection
    myGridColumnCol = dataGrid1.TableStyles(0).GridColumnStyles
    ' Get the CurrencyManager for the table you want to add a column to.
    Dim myCurrencyManager As CurrencyManager = CType(Me.BindingContext(ds.Tables("Suppliers")), CurrencyManager)
    ' Get the PropertyDescriptor for the DataColumn of the new column.
    Dim pd As PropertyDescriptor = myCurrencyManager.GetItemProperties()("City")
    Dim myColumn As New DataGridTextBoxColumn(pd)
    myGridColumnCol.Add(myColumn)
End Sub 'CreateNewDataGridColumnStyle
private void GetPropertyDescriptor()
{
    PropertyDescriptor pd;
    pd = dataGrid1.TableStyles[0].GridColumnStyles[0].PropertyDescriptor;
    Console.WriteLine(pd.ToString());
}
 
private void CreateNewDataGridColumnStyle()
{
    GridColumnStylesCollection myGridColumnCol;
    myGridColumnCol = dataGrid1.TableStyles[0].GridColumnStyles;
    // Get the CurrencyManager for the table you want to add a column to.
    CurrencyManager myCurrencyManager = (CurrencyManager)this.BindingContext[ds.Tables["Suppliers"]];
    // Get the PropertyDescriptor for the DataColumn of the new column.
    PropertyDescriptor pd = myCurrencyManager.GetItemProperties()["City"];
    DataGridColumnStyle myColumn = new DataGridTextBoxColumn(pd);
    myGridColumnCol.Add(myColumn);
 }
private:
   void GetPropertyDescriptor()
   {
      PropertyDescriptor^ pd;
      pd = dataGrid1->TableStyles[ 0 ]->GridColumnStyles[ 0 ]->PropertyDescriptor;
      Console::WriteLine( pd );
   }

   void CreateNewDataGridColumnStyle()
   {
      GridColumnStylesCollection^ myGridColumnCol;
      myGridColumnCol = dataGrid1->TableStyles[ 0 ]->GridColumnStyles;
      
      // Get the CurrencyManager for the table you want to add a column to.
      CurrencyManager^ myCurrencyManager = dynamic_cast<CurrencyManager^>(this->BindingContext[ ds->Tables[ "Suppliers" ] ]);
      
      // Get the PropertyDescriptor for the DataColumn of the new column.
      PropertyDescriptor^ pd = myCurrencyManager->GetItemProperties()[ "City" ];
      DataGridColumnStyle^ myColumn = gcnew DataGridTextBoxColumn( pd );
      myGridColumnCol->Add( myColumn );
   }
private void GetPropertyDescriptor()
{
    PropertyDescriptor pd;
    pd = dataGrid1.get_TableStyles().get_Item(0).
        get_GridColumnStyles().get_Item(0).get_PropertyDescriptor();
    Console.WriteLine(pd.ToString());
} //GetPropertyDescriptor

private void CreateNewDataGridColumnStyle()
{
    GridColumnStylesCollection myGridColumnCol;
    myGridColumnCol = dataGrid1.get_TableStyles().get_Item(0).
        get_GridColumnStyles();
    // Get the CurrencyManager for the table you want to add a column to.
    CurrencyManager myCurrencyManager = 
        (CurrencyManager)(this.get_BindingContext().
        get_Item(ds.get_Tables().get_Item("Suppliers")));
    // Get the PropertyDescriptor for the DataColumn of the new column.
    PropertyDescriptor pd = myCurrencyManager.GetItemProperties().
        get_Item("City");
    DataGridColumnStyle myColumn = new DataGridTextBoxColumn(pd);
    myGridColumnCol.Add(myColumn);
} //CreateNewDataGridColumnStyle

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

DataGridColumnStyle-Klasse
DataGridColumnStyle-Member
System.Windows.Forms-Namespace
Caption
ColumnName
DataType
DataColumn