You can use the CurrentCell property of the DataGrid.
private void button1_Click(object sender, System.EventArgs e)
{
intcolNum = dataGrid1.CurrentCell.ColumnNumber;
int rowNum = dataGrid1.CurrentCell.RowNumber;
object cellValue = dataGrid1[rowNum, colNum];
string s = string.Format('row={0} col={1} value={2}', rowNum, colNum, cellValue);
MessageBox.Show(s);
}
Share with