DataGrid::Item Property (Int32, Int32)
.NET Framework (current version)
Gets or sets the value of the cell at the specified the row and column.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
public: property Object^ default[ int rowIndex, int columnIndex ] { Object^ get(int rowIndex, int columnIndex); void set(int rowIndex, int columnIndex, Object^ value); }
Parameters
- rowIndex
-
Type:
System::Int32
The zero-based index of the row containing the value.
- columnIndex
-
Type:
System::Int32
The zero-based index of the column containing the value.
| Exception | Condition |
|---|---|
| ArgumentOutOfRangeException | While getting or setting, the rowIndex is out of range. While getting or setting, the columnIndex is out of range. |
The following code example prints the value contained by the cell at the specified row and index.
void PrintCellValues( DataGrid^ myGrid ) { int iRow; int iCol; DataTable^ myTable; // Assumes the DataGrid is bound to a DataTable. myTable = dynamic_cast<DataTable^>(dataGrid1->DataSource); for ( iRow = 0; iRow < myTable->Rows->Count; iRow++ ) { for ( iCol = 0; iCol < myTable->Columns->Count; iCol++ ) { Console::WriteLine( myGrid[iRow, iCol] ); } } }
.NET Framework
Available since 1.1
Available since 1.1
Show: