Bewerken

Delen via


GridTableStylesCollection.Item[] Property

Definition

Gets the specified DataGridTableStyle.

Overloads

Item[Int32]

Gets the DataGridTableStyle specified by index.

Item[String]

Gets the DataGridTableStyle with the specified name.

Item[Int32]

Gets the DataGridTableStyle specified by index.

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

Parameters

index
Int32

The index of the DataGridTableStyle to get.

Property Value

The DataGridTableStyle at the specified index.

Exceptions

No item exists at the specified index.

Examples

The following code example returns a DataGridTableStyle from the GridTableStylesCollection by passing an index to the Item[] property.

void GetGridTableByIndex()
{
   DataGridTableStyle^ myGridStyle = myDataGrid->TableStyles[ 0 ];
   Console::WriteLine( myGridStyle->MappingName );
}
private void GetGridTableByIndex()
{
   DataGridTableStyle myGridStyle = 
   myDataGrid.TableStyles[0] ;
   Console.WriteLine(myGridStyle.MappingName);
}
Private Sub GetGridTableByIndex()
   Dim myGridStyle As DataGridTableStyle = _
   myDataGrid.TableStyles(0)
   Console.WriteLine(myGridStyle.MappingName)
End Sub

Remarks

Use the Add or AddRange method to add items to the collection.

Applies to

Item[String]

Gets the DataGridTableStyle with the specified name.

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

Parameters

tableName
String

The MappingName of the DataGridTableStyle to retrieve.

Property Value

The DataGridTableStyle with the specified MappingName.

Examples

The following code example returns a DataGridTableStyle from the GridTableStylesCollection by passing the MappingName to the Item[] property.

void GetGridTableByName()
{
   DataGridTableStyle^ myGridStyle = myDataGrid->TableStyles[ "customers" ];
   Console::WriteLine( myGridStyle->MappingName );
}
private void GetGridTableByName()
{
   DataGridTableStyle myGridStyle = 
   myDataGrid.TableStyles["customers"] ;
   Console.WriteLine(myGridStyle.MappingName);
}
private Sub GetGridTableByName()
   Dim myGridStyle As DataGridTableStyle = _
   myDataGrid.TableStyles("customers")
   Console.WriteLine(myGridStyle.MappingName)
End Sub

Remarks

When retrieving a DataGridTableStyle by MappingName, the Item[] property uses a case-insensitive comparison.

Use the Add or AddRange method to add items to the collection.

Applies to