DataGridCell Struct
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Identifies a cell in the grid.
public value class DataGridCell
public struct DataGridCell
type DataGridCell = struct
Public Structure DataGridCell
- Inheritance
The following example assigns the DataGridCell to the CurrentCell of a System.Windows.Forms.DataGrid and returns the column and row number of the selected cell. The value stored in the DataTable is also printed using the DataGridCell object's RowNumber and ColumnNumber.
void PrintCellRowAndCol()
{
DataGridCell^ myCell;
myCell = DataGrid1->CurrentCell;
Console::WriteLine( myCell->RowNumber );
Console::WriteLine( myCell->ColumnNumber );
// Prints the value of the cell through the DataTable.
DataTable^ myTable;
// Assumes the DataGrid is bound to a DataTable.
myTable = dynamic_cast<DataTable^>(DataGrid1->DataSource);
Console::WriteLine( myTable->Rows[ myCell->RowNumber ][ myCell->ColumnNumber ] );
}
private void PrintCellRowAndCol()
{
DataGridCell myCell;
myCell = DataGrid1.CurrentCell;
Console.WriteLine(myCell.RowNumber);
Console.WriteLine(myCell.ColumnNumber);
// Prints the value of the cell through the DataTable.
DataTable myTable;
// Assumes the DataGrid is bound to a DataTable.
myTable = (DataTable) DataGrid1.DataSource;
Console.WriteLine(myTable.Rows[myCell.RowNumber]
[myCell.ColumnNumber]);
}
Private Sub PrintCellRowAndCol()
Dim myCell As DataGridCell
myCell = DataGrid1.CurrentCell
Console.WriteLine(myCell.RowNumber)
Console.WriteLine(myCell.ColumnNumber)
' Prints the value of the cell through the DataTable.
Dim myTable As DataTable
' Assumes the DataGrid is bound to a DataTable.
myTable = CType(DataGrid1.DataSource, DataTable)
Console.WriteLine(myTable.Rows(myCell.RowNumber)(myCell.ColumnNumber))
End Sub
The DataGridCell can be used in conjunction with the System.Windows.Forms.DataGrid control's CurrentCell property to get or set the value of any cell. Setting the System.Windows.Forms.DataGrid control's CurrentCell property to a DataGridCell causes the focus to move to the cell specified by the DataGridCell.
Data |
Initializes a new instance of the DataGridCell class. |
Column |
Gets or sets the number of a column in the DataGrid control. |
Row |
Gets or sets the number of a row in the DataGrid control. |
Equals(Object) |
Gets a value indicating whether the DataGridCell is identical to a second DataGridCell. |
Get |
Gets a hash value that can be added to a Hashtable. |
To |
Gets the row number and column number of the cell. |
Product | Versions |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: