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

Definition

Overloads

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

Gets the DataGridColumnStyle at a specified index.

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

Gets the DataGridColumnStyle with the specified name.

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

Gets the DataGridColumnStyle associated with the specified PropertyDescriptor.

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

Gets 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

Parameters

index
Int32 Int32 Int32 Int32

The zero-based index of the DataGridColumnStyle to return.

Property Value

Examples

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 

Remarks

Use the IndexOf method to determine the index of any element in the collection.

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

Gets 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

Parameters

columnName
String String String String

The MappingName of the DataGridColumnStyle to retrieve.

Property Value

Examples

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 

Remarks

The column header of a DataGridColumnStyle can be set explicitly by setting the HeaderText property. 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]

Gets 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

Parameters

Property Value

Examples

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 

Remarks

Each DataGridColumnStyle is created using a PropertyDescriptor. The PropertyDescriptor can be returned using the PropertyDescriptor property.

To get the PropertyDescriptorCollection for a specific data source, use the GetItemProperties method of the BindingManagerBase class. Pass the MappingName to the Item[String] property of the PropertyDescriptorCollection to return a PropertyDescriptor for a specific column.

See also

Applies to