GridColumnStylesCollection.Item[] Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan yang ditentukan DataGridColumnStyle dalam GridColumnStylesCollection.
Overload
| Nama | Deskripsi |
|---|---|
| Item[Int32] |
Mendapatkan pada DataGridColumnStyle indeks tertentu. |
| Item[String] |
DataGridColumnStyle Mendapatkan dengan nama yang ditentukan. |
| Item[PropertyDescriptor] |
Mendapatkan yang DataGridColumnStyle terkait dengan yang ditentukan PropertyDescriptor. |
Item[Int32]
Mendapatkan pada DataGridColumnStyle indeks tertentu.
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
Parameter
- index
- Int32
Indeks berbasis nol dari yang DataGridColumnStyle akan dikembalikan.
Nilai Properti
Yang ditentukan DataGridColumnStyle.
Contoh
Contoh kode berikut mendapatkan DataGridColumnStyle menggunakan Item[] properti .
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
Keterangan
IndexOf Gunakan metode untuk menentukan indeks elemen apa pun dalam koleksi.
Berlaku untuk
Item[String]
DataGridColumnStyle Mendapatkan dengan nama yang ditentukan.
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
Parameter
- columnName
- String
Dari MappingName yang DataGridColumnStyle akan diambil.
Nilai Properti
DataGridColumnStyle dengan header kolom yang ditentukan.
Contoh
Contoh kode berikut mengembalikan yang dinamai DataGridColumnStyleItem[] dalam properti .
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
Keterangan
Header DataGridColumnStyle kolom dapat diatur secara eksplisit dengan mengatur HeaderText properti . Secara default, HeaderText diatur menggunakan nilai MappingName properti.
Perbandingan antara header kolom dan nilai yang akan dicari tidak peka huruf besar/kecil.
Berlaku untuk
Item[PropertyDescriptor]
Mendapatkan yang DataGridColumnStyle terkait dengan yang ditentukan 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
Parameter
- propDescpropertyDesciptor
- PropertyDescriptor
Yang PropertyDescriptor terkait dengan DataGridColumnStyle.
Nilai Properti
Yang DataGridColumnStyle terkait dengan yang ditentukan PropertyDescriptor.
Contoh
Contoh kode berikut mendapatkan DataColumn dari DataTable dalam DataSet, lalu meneruskannya sebagai argumen ke Add metode .
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
Keterangan
Masing-masing DataGridColumnStyle dibuat menggunakan PropertyDescriptor. PropertyDescriptor dapat dikembalikan menggunakan PropertyDescriptor properti .
Untuk mendapatkan PropertyDescriptorCollection sumber data tertentu, gunakan GetItemProperties metode BindingManagerBase kelas . Teruskan MappingName ke Item[] properti PropertyDescriptorCollection untuk mengembalikan PropertyDescriptor kolom tertentu.