Reputation: 5299
I have a DevExpress GridControl. I want to handle a row doubleclicks with it. I do:
private void УчасткиGridControlDoubleClick(object sender, EventArgs e)
{
GridControl grid = sender as GridControl;
DXMouseEventArgs args = e as DXMouseEventArgs;
var hitInfo = grid.Views[0].CalcHitInfo(args.Location) as GridHitInfo;
MessageBox.Show(hitInfo.HitTest.ToString());
}
But i get message only if click on Row Indicator or Column Header.
How to handle clicks on row's cells?
Upvotes: 2
Views: 12855
Reputation: 10286
Basically you should Handle GridView.DoubleClick
private void УчасткиGridControlDoubleClick(object sender, EventArgs e) {
GridView view = (GridView)sender;
Point pt = view.GridControl.PointToClient(Control.MousePosition);
DoRowDoubleClick(view, pt);
}
private static void DoRowDoubleClick(GridView view, Point pt) {
GridHitInfo info = view.CalcHitInfo(pt);
if(info.InRow || info.InRowCell) {
string colCaption = info.Column == null ? "N/A" : info.Column.GetCaption();
MessageBox.Show(string.Format("DoubleClick on row: {0}, column: {1}.", info.RowHandle, colCaption));
}
For more please refer to Devexpress Double Click
Note: This code works only when your grid is not editable
Upvotes: 5