NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

DataGrid.Item (Int32, Int32)

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.

Arguments [JScript]

rowIndex
The zero-based index of the row containing the value.
columnIndex
The zero-based index of the column containing the value.

Parameters [Visual Basic, C#, C++]

rowIndex
The zero-based index of the row containing the value.
columnIndex
The zero-based index of the column containing the value.

Property Value

The value of the cell specified by the rowIndex and columnIndex parameters.

Exceptions

Exception Type Condition
ArgumentOutOfRangeException While getting or setting, the rowIndex is out of range.

While getting or setting, the columnIndex is out of range.

Remarks

Setting this property changes the position of the DataView to the specified row.

Example [Visual Basic]

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

See Also

DataGrid Class | DataGrid Members | System.WinForms Namespace | DataGrid.Item Overload List