gpt4 book ai didi

c# - 如何处理 GridView 中的行双击?

转载 作者:行者123 更新时间:2023-12-02 21:42:09 25 4
gpt4 key购买 nike

我有一个 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));

}

更多请引用Devexpress Double Click

注意:仅当您的网格不可编辑时,此代码才有效

关于c# - 如何处理 GridView 中的行双击?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20188172/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com