I can't get column name of clicked cell in GridControl of XtraGrid. How can I do that? I'm handling GridView.Click
event.
Asked
Active
Viewed 2.8k times
1 Answers
22
Within the click event you can resolve the clicked cell as follows:
void gridView_Click(object sender, EventArgs e) {
Point clickPoint = gridControl.PointToClient(Control.MousePosition);
var hitInfo = gridView.CalcHitInfo(clickPoint);
if(hitInfo.InRowCell) {
int rowHandle = hitInfo.RowHandle;
GridColumn column = hitInfo.Column;
}
}
However, I suggest you handle the GridView.MouseDown event as follows (because the GridView.Click event does not occur if clicking a grid cell activates a column editor):
gridView.MouseDown += new MouseEventHandler(gridView_MouseDown);
//...
void gridView_MouseDown(object sender, MouseEventArgs e) {
var hitInfo = gridView.CalcHitInfo(e.Location);
if(hitInfo.InRowCell) {
int rowHandle = hitInfo.RowHandle;
GridColumn column = hitInfo.Column;
}
}
Related link: Hit Information Overview

DmitryG
- 17,677
- 1
- 30
- 53
-
How can I do this in devexpress mvc? – Sнаđошƒаӽ May 16 '17 at 11:46