Поделиться через


GridColumnStylesCollection.Item[] Свойство

Определение

Возвращает указанный DataGridColumnStyle в объекте GridColumnStylesCollection.

Перегрузки

Имя Описание
Item[Int32]

DataGridColumnStyle Возвращает указанный индекс.

Item[String]

Возвращает указанное DataGridColumnStyle имя.

Item[PropertyDescriptor]

Возвращает связанный DataGridColumnStyle с указанным PropertyDescriptor.

Item[Int32]

Исходный код:
GridColumnStylesCollection.cs
Исходный код:
GridColumnStylesCollection.cs

DataGridColumnStyle Возвращает указанный индекс.

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

Отсчитываемый от нуля индекс возвращаемого DataGridColumnStyle объекта.

Значение свойства

Указанный DataGridColumnStyle.

Примеры

В следующем примере кода показано, как DataGridColumnStyleItem[] использовать свойство.

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 Используйте метод, чтобы определить индекс любого элемента в коллекции.

Применяется к

Item[String]

Исходный код:
GridColumnStylesCollection.cs
Исходный код:
GridColumnStylesCollection.cs

Возвращает указанное DataGridColumnStyle имя.

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

Извлекаемая MappingNameDataGridColumnStyle часть.

Значение свойства

С DataGridColumnStyle указанным заголовком столбца.

Примеры

В следующем примере кода возвращается именованное DataGridColumnStyle в свойстве 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

Комментарии

Заголовок столбца DataGridColumnStyle можно задать явно, задав HeaderText свойство. По умолчанию используется HeaderTextMappingName значение свойства.

Сравнение заголовков столбцов и значения для поиска не учитывает регистр.

Применяется к

Item[PropertyDescriptor]

Исходный код:
GridColumnStylesCollection.cs
Исходный код:
GridColumnStylesCollection.cs

Возвращает связанный DataGridColumnStyle с указанным 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

Параметры

propDescpropertyDesciptor
PropertyDescriptor

Связанный PropertyDescriptorDataGridColumnStyleс .

Значение свойства

Связанный DataGridColumnStyle указанный PropertyDescriptorобъект.

Примеры

Следующий пример кода получает DataColumn от объекта DataTable в объекте DataSet, а затем передает его в качестве аргумента методу Add .

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. Его PropertyDescriptor можно вернуть с помощью PropertyDescriptor свойства.

Чтобы получить PropertyDescriptorCollection определенный источник данных, используйте GetItemProperties метод BindingManagerBase класса. MappingName Item[] Передайте свойство PropertyDescriptorCollection возвращаемого PropertyDescriptor столбца свойству объекта.

См. также раздел

Применяется к