GridColumnStylesCollection.Item[] Propriedade

Definição

Sobrecargas

Item[Int32]

Obtém o DataGridColumnStyle em um índice especificado.Gets the DataGridColumnStyle at a specified index.

Item[String]

Obtém o DataGridColumnStyle com o nome especificado.Gets the DataGridColumnStyle with the specified name.

Item[PropertyDescriptor]

Obtém o DataGridColumnStyle associado ao PropertyDescriptor especificado.Gets the DataGridColumnStyle associated with the specified PropertyDescriptor.

Item[Int32]

Obtém o DataGridColumnStyle em um índice especificado.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

Parâmetros

index
Int32

O índice com base em zero do DataGridColumnStyle a ser retornado.The zero-based index of the DataGridColumnStyle to return.

Valor da propriedade

DataGridColumnStyle

O DataGridColumnStyle especificado.The specified DataGridColumnStyle.

Exemplos

O exemplo de código a seguir obtém o DataGridColumnStyle usando a Item[] propriedade.The following code example gets the DataGridColumnStyle using the Item[] 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 

Comentários

Use o IndexOf método para determinar o índice de qualquer elemento na coleção.Use the IndexOf method to determine the index of any element in the collection.

Aplica-se a

Item[String]

Obtém o DataGridColumnStyle com o nome especificado.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

Parâmetros

columnName
String

O MappingName do DataGridColumnStyle a recuperar.The MappingName of the DataGridColumnStyle to retrieve.

Valor da propriedade

DataGridColumnStyle

O DataGridColumnStyle com o cabeçalho de coluna especificado.The DataGridColumnStyle with the specified column header.

Exemplos

O exemplo de código a seguir retorna o DataGridColumnStyle nomeado na Item[] propriedade.The following code example returns the DataGridColumnStyle named in the Item[] 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 

Comentários

O cabeçalho da coluna de a DataGridColumnStyle pode ser definido explicitamente definindo a HeaderText propriedade.The column header of a DataGridColumnStyle can be set explicitly by setting the HeaderText property. Por padrão, o HeaderText é definido usando o MappingName valor da propriedade use.By default, the HeaderText is set using uses MappingName property value.

A comparação entre os cabeçalhos de coluna e o valor a ser procurada não diferencia maiúsculas de minúsculas.The comparison between column headers and the value to look for is not case-sensitive.

Aplica-se a

Item[PropertyDescriptor]

Obtém o DataGridColumnStyle associado ao PropertyDescriptor especificado.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 ^ propertyDesciptor); };
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 propertyDesciptor] { get; }
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(propertyDesciptor As PropertyDescriptor) As DataGridColumnStyle
Default Public ReadOnly Property Item(propDesc As PropertyDescriptor) As DataGridColumnStyle

Parâmetros

propertyDesciptorpropDesc
PropertyDescriptor

O PropertyDescriptor associado ao DataGridColumnStyle.The PropertyDescriptor associated with the DataGridColumnStyle.

Valor da propriedade

DataGridColumnStyle

O DataGridColumnStyle especificado associado PropertyDescriptor .The DataGridColumnStyle associated the specified PropertyDescriptor.

Exemplos

O exemplo de código a seguir obtém um DataColumn de um DataTable em DataSet e, em seguida, passa-o como um argumento para o Add método.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 

Comentários

Cada DataGridColumnStyle um é criado usando um PropertyDescriptor .Each DataGridColumnStyle is created using a PropertyDescriptor. O PropertyDescriptor pode ser retornado usando a PropertyDescriptor propriedade.The PropertyDescriptor can be returned using the PropertyDescriptor property.

Para obter o PropertyDescriptorCollection para uma fonte de dados específica, use o GetItemProperties método da BindingManagerBase classe.To get the PropertyDescriptorCollection for a specific data source, use the GetItemProperties method of the BindingManagerBase class. Passe o MappingName para a Item[] Propriedade do PropertyDescriptorCollection para retornar um PropertyDescriptor para uma coluna específica.Pass the MappingName to the Item[] property of the PropertyDescriptorCollection to return a PropertyDescriptor for a specific column.

Confira também

Aplica-se a