GridColumnStylesCollection.Item[] Egenskap

Definition

Överlagringar

Name Description
Item[Int32]

Hämtar vid DataGridColumnStyle ett angivet index.

Item[String]

DataGridColumnStyle Hämtar med det angivna namnet.

Item[PropertyDescriptor]

Hämtar den DataGridColumnStyle associerade med den angivna PropertyDescriptor.

Item[Int32]

Källa:
GridColumnStylesCollection.cs
Källa:
GridColumnStylesCollection.cs

Hämtar vid DataGridColumnStyle ett angivet 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

Parametrar

index
Int32

Det nollbaserade indexet för att DataGridColumnStyle returnera.

Egenskapsvärde

Den angivna DataGridColumnStyle.

Exempel

I följande kodexempel hämtas DataGridColumnStyle egenskapen .Item[]

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

Kommentarer

IndexOf Använd metoden för att fastställa indexet för alla element i samlingen.

Gäller för

Item[String]

Källa:
GridColumnStylesCollection.cs
Källa:
GridColumnStylesCollection.cs

DataGridColumnStyle Hämtar med det angivna namnet.

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

Parametrar

columnName
String

För MappingName att DataGridColumnStyle hämta.

Egenskapsvärde

Med DataGridColumnStyle den angivna kolumnrubriken.

Exempel

Följande kodexempel returnerar det namngivna DataGridColumnStyle i egenskapen Item[] .

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

Kommentarer

Kolumnrubriken för en DataGridColumnStyle kan anges explicit genom att ange egenskapen HeaderText . Som standard HeaderText anges med hjälp av MappingName egenskapsvärdet.

Jämförelsen mellan kolumnrubriker och det värde som ska sökas efter är inte skiftlägeskänslig.

Gäller för

Item[PropertyDescriptor]

Källa:
GridColumnStylesCollection.cs
Källa:
GridColumnStylesCollection.cs

Hämtar den DataGridColumnStyle associerade med den angivna PropertyDescriptor.

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

Parametrar

propDescpropertyDesciptor
PropertyDescriptor

Associerad PropertyDescriptor med DataGridColumnStyle.

Egenskapsvärde

Den DataGridColumnStyle associerade angivna PropertyDescriptor.

Exempel

Följande kodexempel hämtar en DataColumn från en DataTable i en DataSetoch skickar den sedan som ett argument till Add metoden.

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

Kommentarer

Var och DataGridColumnStyle en skapas med hjälp av en PropertyDescriptor. PropertyDescriptor Kan returneras med hjälp av PropertyDescriptor egenskapen .

Om du vill hämta PropertyDescriptorCollection för en specifik datakälla använder du GetItemProperties -metoden för BindingManagerBase klassen. MappingName Skicka till Item[] egenskapen för PropertyDescriptorCollection för att returnera en PropertyDescriptor för en specifik kolumn.

Se även

Gäller för