For selected column and row:
private void myDataGridView_MouseDown(object sender, MouseEventArgs e)
{
int ColumnIndex =myDataGridView.SelectedColumns[0].Index; // Selected Column Index
int RowIndex = myDataGridView.SelectedRows[0].Index; // Selected Row Index
}
For click location use:
DataGridView.HitTestInfo myHit = dataGridView1.HitTest(e.X, e.Y);
if (myHit.Type == DataGridViewHitTestType.Cell)
{
// select row == myHit.RowIndex;
}
No comments:
Post a Comment