Share via


DataGridColumnStyle.PropertyDescriptor 属性

获取或设置 PropertyDescriptor,它确定 DataGridColumnStyle 所显示数据的属性。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public Overridable Property PropertyDescriptor As PropertyDescriptor
用法
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)

属性值

一个 PropertyDescriptor,它包含有关列的属性的数据。

备注

使用 BindingManagerBaseGetItemProperties 方法设置列的 PropertyDescriptor。有关使用 PropertyDescriptor 创建新 DataGridColumnStyle 的示例,请参见 DataGridColumnStyle 构造函数。

示例

下面的代码示例获取 GridColumnStylesCollection 中某列的 PropertyDescriptor。第二个示例使用 PropertyDescriptor 创建一个新的 DataGridColumnStyle

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

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

DataGridColumnStyle 类
DataGridColumnStyle 成员
System.Windows.Forms 命名空间
Caption
ColumnName
DataType
DataColumn