DataGridView.Item[] 屬性

定義

提供索引子以取得或設定位於指定資料列和資料行交集處的儲存格。

多載

Item[Int32, Int32]

提供索引子以取得或設定位於具有指定索引之資料行和資料列交集處的儲存格。

Item[String, Int32]

提供索引子以取得或設定位於具有指定索引的資料列以及具有指定名稱的資料行二者交集處的儲存格。

Item[Int32, Int32]

提供索引子以取得或設定位於具有指定索引之資料行和資料列交集處的儲存格。

public:
 property System::Windows::Forms::DataGridViewCell ^ default[int, int] { System::Windows::Forms::DataGridViewCell ^ get(int columnIndex, int rowIndex); void set(int columnIndex, int rowIndex, System::Windows::Forms::DataGridViewCell ^ value); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.DataGridViewCell this[int columnIndex, int rowIndex] { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.Item(int * int) : System.Windows.Forms.DataGridViewCell with get, set
Default Public Property Item(columnIndex As Integer, rowIndex As Integer) As DataGridViewCell

參數

columnIndex
Int32

包含儲存格的資料行之索引。

rowIndex
Int32

包含儲存格的資料列之索引。

屬性值

DataGridViewCell

位於指定位置處的 DataGridViewCell

屬性

例外狀況

columnIndex 小於 0,或大於控制項中的資料行數目減 1。

-或- rowIndex 小於 0,或大於控制項中的資料列數目減 1。

範例

下列程式碼範例示範如何使用這個索引子。

// Retrieve the cell value for the cell at column 3, row 7.
String testValue1 = (String)dataGridView1[3, 7].Value;

// Retrieve the cell value for the cell in the Name column at row 4.
String testValue2 = (String)dataGridView1["Name", 4].Value;
' Retrieve the cell value for the cell at column 3, row 7.
Dim testValue1 As String = CStr(dataGridView1(3, 7).Value)

' Retrieve the cell value for the cell in the Name column at row 4.
Dim testValue2 As String = CStr(dataGridView1("Name", 4).Value)

備註

這個索引子是透過集合集合存取儲存格 CellsRows 替代方法。

另請參閱

適用於

Item[String, Int32]

提供索引子以取得或設定位於具有指定索引的資料列以及具有指定名稱的資料行二者交集處的儲存格。

public:
 property System::Windows::Forms::DataGridViewCell ^ default[System::String ^, int] { System::Windows::Forms::DataGridViewCell ^ get(System::String ^ columnName, int rowIndex); void set(System::String ^ columnName, int rowIndex, System::Windows::Forms::DataGridViewCell ^ value); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.DataGridViewCell this[string columnName, int rowIndex] { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.Item(string * int) : System.Windows.Forms.DataGridViewCell with get, set
Default Public Property Item(columnName As String, rowIndex As Integer) As DataGridViewCell

參數

columnName
String

包含儲存格的資料行名稱。

rowIndex
Int32

包含儲存格的資料列之索引。

屬性值

DataGridViewCell

位於指定位置處的 DataGridViewCell

屬性

範例

下列程式碼範例示範如何使用這個索引子。

// Retrieve the cell value for the cell at column 3, row 7.
String testValue1 = (String)dataGridView1[3, 7].Value;

// Retrieve the cell value for the cell in the Name column at row 4.
String testValue2 = (String)dataGridView1["Name", 4].Value;
' Retrieve the cell value for the cell at column 3, row 7.
Dim testValue1 As String = CStr(dataGridView1(3, 7).Value)

' Retrieve the cell value for the cell in the Name column at row 4.
Dim testValue2 As String = CStr(dataGridView1("Name", 4).Value)

備註

這個索引子是透過集合集合存取儲存格 CellsRows 替代方法。

另請參閱

適用於