Live Chat Icon For mobile
Live Chat Icon

How do I get the row and column of the current cell in my datagrid

Platform: WinForms| Category: Datagrid

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

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.