Gets or sets the value of the cell at the specified the row and column.
[C#] In C#, this member is the indexer for the DataGrid class.
[Visual Basic] Overloads Public Default Property Item( _ ByVal rowIndex As Integer, _ ByVal columnIndex As Integer _ ) As Object [C#] public object this[ int rowIndex, int columnIndex ] {get; set;} [C++] public: __property Object* get_Item( int rowIndex, int columnIndex ); public: __property void set_Item( int rowIndex, int columnIndex, Object* ); [JScript] returnValue = DataGridObject.Item(rowIndex, columnIndex); DataGridObject.Item(rowIndex, columnIndex) = returnValue; -or- returnValue = DataGridObject(rowIndex, columnIndex); DataGridObject(rowIndex, columnIndex) = returnValue;
[JScript] In JScript, you can use the default indexed properties defined by a type, but you cannot explicitly define your own. However, specifying the expando attribute on a class automatically provides a default indexed Item property whose type is Object and whose index type is String.
The value of the cell specified by the rowIndex and columnIndex parameters.
Exception Type | Condition |
---|---|
ArgumentOutOfRangeException | While getting or setting, the rowIndex is out of range.
While getting or setting, the columnIndex is out of range. |
Setting this property changes the position of the DataView to the specified row.
The following example prints the value contained by the cell at the specified row and index.
[Visual Basic]
Private Sub PrintCells(ByVal myGrid As DataGrid) Dim iRow As Integer Dim iCol As Integer For iRow = 0 To myGrid.CurrentGridTable.DataTable.Rows.Count - 1 For iCol = 0 To myGrid.CurrentGridTable.DataTable.Columns.Count - 1 Console.WriteLine(myGrid(iRow, iCol).ToString & ", ") Next iCol Console.WriteLine Next iRow End Sub
DataGrid Class | DataGrid Members | System.WinForms Namespace | DataGrid.Item Overload List