Gets or sets the value of a specified DataGridCell.
[C#] In C#, this member is the indexer for the DataGrid class.
[Visual Basic] Overloads Public Default Property Item( _ ByVal cell As DataGridCell _ ) As Object [C#] public object this[ DataGridCell cell ] {get; set;} [C++] public: __property Object* get_Item( DataGridCell cell ); public: __property void set_Item( DataGridCell cell, Object* ); [JScript] returnValue = DataGridObject.Item(cell); DataGridObject.Item(cell) = returnValue; -or- returnValue = DataGridObject(cell); DataGridObject(cell) = 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.
Setting this property changes the position of the DataView to the specified row.
The following example sets and gets the value of a cell by declaring a DataGridCell variable, setting its RowNumber and ColumnNumber values, then first changing, then returning, the value of the given cell.
[Visual Basic]
Private Sub SetCellValue() Dim myCell As DataGridCell ' Use an arbitrary cell. myCell.RowNumber = 0 myCell.ColumnNumber = 0 ' Change the cell's value using the CurrentCell DataGrid1(myCell)= "New Value" End Sub Private Sub GetCellValue() Dim myCell = DataGridCell ' Use an arbitrary cell. myCell.RowNumber = 0 myCell.ColumnNumber = 0 Console.WriteLine(DataGrid1(myCell)) End Sub
DataGrid Class | DataGrid Members | System.WinForms Namespace | DataGrid.Item Overload List | CurrentCell | DataGridCell