Share via


DataGridViewCellCollection.Item[] 屬性

定義

取得或設定在提供的位置上的項目。 在 C# 中,這個屬性是 DataGridViewCellCollection 類別的索引子。

多載

Item[Int32]

取得或設定在提供的索引位置上的儲存格。 在 C# 中,這個屬性是 DataGridViewCellCollection 類別的索引子。

Item[String]

取得或設定在資料行中具有指定名稱的儲存格。 在 C# 中,這個屬性是 DataGridViewCellCollection 類別的索引子。

Item[Int32]

取得或設定在提供的索引位置上的儲存格。 在 C# 中,這個屬性是 DataGridViewCellCollection 類別的索引子。

public:
 property System::Windows::Forms::DataGridViewCell ^ default[int] { System::Windows::Forms::DataGridViewCell ^ get(int index); void set(int index, System::Windows::Forms::DataGridViewCell ^ value); };
public System.Windows.Forms.DataGridViewCell this[int index] { get; set; }
member this.Item(int) : System.Windows.Forms.DataGridViewCell with get, set
Default Public Property Item(index As Integer) As DataGridViewCell

參數

index
Int32

要取得或設定的儲存格之以零起始的索引。

屬性值

指定索引處所儲存的 DataGridViewCell

例外狀況

設定這個屬性時所指定的值是 null

所指定的儲存格在設定此屬性時已經屬於 DataGridView 控制項。

-或-

所指定的儲存格在設定此屬性時已經屬於 DataGridViewRow 控制項。

index 小於 0。

-或-

index 等於或大於集合中的儲存格數目。

另請參閱

適用於

Item[String]

取得或設定在資料行中具有指定名稱的儲存格。 在 C# 中,這個屬性是 DataGridViewCellCollection 類別的索引子。

public:
 property System::Windows::Forms::DataGridViewCell ^ default[System::String ^] { System::Windows::Forms::DataGridViewCell ^ get(System::String ^ columnName); void set(System::String ^ columnName, System::Windows::Forms::DataGridViewCell ^ value); };
public System.Windows.Forms.DataGridViewCell this[string columnName] { get; set; }
member this.Item(string) : System.Windows.Forms.DataGridViewCell with get, set
Default Public Property Item(columnName As String) As DataGridViewCell

參數

columnName
String

資料行的名稱,要在其中取得或設定儲存格。

屬性值

存放在資料行中的指定名稱之 DataGridViewCell

例外狀況

columnName 不符合控制項中任何資料行的名稱。

設定這個屬性時所指定的值是 null

所指定的儲存格在設定此屬性時已經屬於 DataGridView 控制項。

-或-

所指定的儲存格在設定此屬性時已經屬於 DataGridViewRow 控制項。

另請參閱

適用於