Gets or sets the value of a cell.
[C#] In C#, this member is the indexer for the DataGrid class.
Gets or sets the value of the cell at the specified the row and column.
[Visual Basic] Overloads Public Default Property Item(Integer, Integer) As Object
[C#] public object this[int, int] {get; set;}
[C++] public: __property Object* get_Item(int, int);
public: __property void set_Item(int, int, Object*);
[JScript] DataGrid.Item (int, int)
Gets or sets the value of a specified DataGridCell.
[Visual Basic] Overloads Public Default Property Item(DataGridCell) As Object
[C#] public object this[DataGridCell] {get; set;}
[C++] public: __property Object* get_Item(DataGridCell);
public: __property void set_Item(DataGridCell, Object*);
[JScript] DataGrid.Item (DataGridCell)
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.
Note This example shows how to use one of the overloaded versions of the Item property (DataGrid indexer). For other examples that may be available, see the individual overload topics.
[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