DataGridView.Item[] Propiedad

Definición

Proporciona un indexador para obtener o establecer la celda ubicada en la intersección de la fila y columna especificadas.

Sobrecargas

Nombre Description
Item[Int32, Int32]

Proporciona un indexador para obtener o establecer la celda ubicada en la intersección de la columna y fila con los índices especificados.

Item[String, Int32]

Proporciona un indexador para obtener o establecer la celda ubicada en la intersección de la fila con el índice especificado y la columna con el nombre especificado.

Item[Int32, Int32]

Proporciona un indexador para obtener o establecer la celda ubicada en la intersección de la columna y fila con los índices especificados.

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

Parámetros

columnIndex
Int32

Índice de la columna que contiene la celda.

rowIndex
Int32

Índice de la fila que contiene la celda.

Valor de propiedad

en DataGridViewCell la ubicación especificada.

Atributos

Excepciones

columnIndex es menor que 0 o mayor que el número de columnas del control menos 1.

O bien

rowIndex es menor que 0 o mayor que el número de filas del control menos 1.

Ejemplos

En el ejemplo de código siguiente se muestra el uso de este indexador.

// 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)

Comentarios

Este indexador es una alternativa a acceder a las celdas a través de la Cells colección de la Rows colección.

Consulte también

Se aplica a

Item[String, Int32]

Proporciona un indexador para obtener o establecer la celda ubicada en la intersección de la fila con el índice especificado y la columna con el nombre especificado.

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

Parámetros

columnName
String

Nombre de la columna que contiene la celda.

rowIndex
Int32

Índice de la fila que contiene la celda.

Valor de propiedad

en DataGridViewCell la ubicación especificada.

Atributos

Ejemplos

En el ejemplo de código siguiente se muestra el uso de este indexador.

// 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)

Comentarios

Este indexador es una alternativa a acceder a las celdas a través de la Cells colección de la Rows colección.

Consulte también

Se aplica a