GridColumnStylesCollection.Item[PropertyDescriptor] GridColumnStylesCollection.Item[PropertyDescriptor] GridColumnStylesCollection.Item[PropertyDescriptor] GridColumnStylesCollection.Item[PropertyDescriptor] Property

定义

重载

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

获取指定索引处的 DataGridColumnStyleGets the DataGridColumnStyle at a specified index.

Item[String] Item[String] Item[String] Item[String]

获取具有指定名称的 DataGridColumnStyleGets the DataGridColumnStyle with the specified name.

Item[PropertyDescriptor] Item[PropertyDescriptor] Item[PropertyDescriptor] Item[PropertyDescriptor]

获取与指定 DataGridColumnStyle 关联的 PropertyDescriptorGets the DataGridColumnStyle associated with the specified PropertyDescriptor.

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

获取指定索引处的 DataGridColumnStyleGets the DataGridColumnStyle at a specified index.

public:
 property System::Windows::Forms::DataGridColumnStyle ^ default[int] { System::Windows::Forms::DataGridColumnStyle ^ get(int index); };
public System.Windows.Forms.DataGridColumnStyle this[int index] { get; }
member this.Item(int) : System.Windows.Forms.DataGridColumnStyle
Default Public ReadOnly Property Item(index As Integer) As DataGridColumnStyle

参数

index
Int32 Int32 Int32 Int32

要返回的 DataGridColumnStyle 的从零开始的索引。The zero-based index of the DataGridColumnStyle to return.

属性值

示例

下面的代码示例DataGridColumnStyle Item[PropertyDescriptor]使用属性获取。The following code example gets the DataGridColumnStyle using the Item[PropertyDescriptor] property.

Private Sub GetGridColumn()
    Dim myDataGridColumnStyle As DataGridColumnStyle 
    ' Get the DataGridColumnStyle at the specified index.
    myDataGridColumnStyle = _
    DataGrid1.TableStyles(0).GridColumnStyles(0)
    Console.WriteLine(myDataGridColumnStyle.MappingName)
End Sub 

注解

IndexOf使用方法可确定集合中任何元素的索引。Use the IndexOf method to determine the index of any element in the collection.

Item[String] Item[String] Item[String] Item[String]

获取具有指定名称的 DataGridColumnStyleGets the DataGridColumnStyle with the specified name.

public:
 property System::Windows::Forms::DataGridColumnStyle ^ default[System::String ^] { System::Windows::Forms::DataGridColumnStyle ^ get(System::String ^ columnName); };
public System.Windows.Forms.DataGridColumnStyle this[string columnName] { get; }
member this.Item(string) : System.Windows.Forms.DataGridColumnStyle
Default Public ReadOnly Property Item(columnName As String) As DataGridColumnStyle

参数

columnName
String String String String

要检索的 DataGridColumnStyleMappingNameThe MappingName of the DataGridColumnStyle to retrieve.

属性值

示例

下面的代码示例在DataGridColumnStyle Item[PropertyDescriptor]属性中返回指定的。The following code example returns the DataGridColumnStyle named in the Item[PropertyDescriptor] property.

Private Sub GetGridColumn()
    Dim myDataGridColumnStyle As DataGridColumnStyle 
    ' Get the DataGridColumnStyle at the specified index.
    myDataGridColumnStyle = _
    DataGrid1.TableStyles(0).GridColumnStyles("Fname")
    Console.WriteLine(myDataGridColumnStyle.MappingName)
End Sub 

注解

可以通过DataGridColumnStyle HeaderText设置属性显式设置的列标题。The column header of a DataGridColumnStyle can be set explicitly by setting the HeaderText property. 默认情况下, HeaderText使用 "使用MappingName " 属性值设置。By default, the HeaderText is set using uses MappingName property value.

列标题和要查找的值之间的比较不区分大小写。The comparison between column headers and the value to look for is not case-sensitive.

Item[PropertyDescriptor] Item[PropertyDescriptor] Item[PropertyDescriptor] Item[PropertyDescriptor]

获取与指定 DataGridColumnStyle 关联的 PropertyDescriptorGets the DataGridColumnStyle associated with the specified PropertyDescriptor.

public:
 property System::Windows::Forms::DataGridColumnStyle ^ default[System::ComponentModel::PropertyDescriptor ^] { System::Windows::Forms::DataGridColumnStyle ^ get(System::ComponentModel::PropertyDescriptor ^ propDesc); };
public System.Windows.Forms.DataGridColumnStyle this[System.ComponentModel.PropertyDescriptor propDesc] { get; }
member this.Item(System.ComponentModel.PropertyDescriptor) : System.Windows.Forms.DataGridColumnStyle
Default Public ReadOnly Property Item(propDesc As PropertyDescriptor) As DataGridColumnStyle

参数

属性值

示例

下面的DataColumn代码示例从中DataSetDataTable获取, Add然后将其作为参数传递给方法。The following code example gets a DataColumn from a DataTable in a DataSet, and then passes it as an argument to the Add method.

Private Sub ContainsThisDataCol()
    Dim myPropertyDescriptor As PropertyDescriptor
    Dim myPropertyDescriptorCollection As PropertyDescriptorCOllection
    myPropertyDescriptorCollection = _
    me.BindingContext(DataSet1, "Customers").GetItemProperties()
    myPropertyDescriptor = myPropertyDescriptorCollection("FirstName")

    Dim myDataGridColumnStyle As DataGridColumnStyle
    myDataGridColumnStyle = DataGrid1.TableStyles(0). _
    GridColumnStyles(myPropertyDescriptor)
End Sub 

注解

DataGridColumnStyle个都PropertyDescriptor使用创建。Each DataGridColumnStyle is created using a PropertyDescriptor. PropertyDescriptor 可以PropertyDescriptor使用属性返回。The PropertyDescriptor can be returned using the PropertyDescriptor property.

若要获取PropertyDescriptorCollection特定数据源的,请GetItemProperties使用BindingManagerBase类的方法。To get the PropertyDescriptorCollection for a specific data source, use the GetItemProperties method of the BindingManagerBase class. 将传递MappingName PropertyDescriptor到的Item[String] PropertyDescriptorCollection属性,以返回特定列的。Pass the MappingName to the Item[String] property of the PropertyDescriptorCollection to return a PropertyDescriptor for a specific column.

另请参阅

适用于