我有一个 DevExpress GridControl。我想用它处理一行双击。我愿意:
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());
}
但仅当单击行指示器或列标题时我才会收到消息。
如何处理行单元格上的点击?
最佳答案
基本上你应该处理 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));
}
注意:仅当您的网格不可编辑时,此代码才有效
关于c# - 如何处理 GridView 中的行双击?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20188172/