作者:.NET开发
项目:System.Windows.Form
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]);
}