1

目前,当我双击任何网格项目时,会触发以下事件。这包括如果我也双击标题。

有没有办法区分标题或点击的行?SelectedItem 位置始终 > 0

this.grdItems = new Janus.Windows.GridEX.GridEX();
...
this.grdItems.DoubleClick += new System.EventHandler(this.grdItems_DoubleClick);

private void grdItems_DoubleClick(object sender, System.EventArgs e)
    { 
        if (grdItems.SelectedItems!=null && grdItems.SelectedItems[0].Position >= 0)
        {
          //doing something
        }
    }
4

2 回答 2

0
private void mxGridExJanus1_RowDoubleClick(object sender, Janus.Windows.GridEX.RowActionEventArgs e)
{
    if (e.Row.RowType != RowType.Record) return;

    // row clicked
}
于 2019-08-04T13:36:17.323 回答
0

一种方法是使用HitTest()方法

声明你的变量

public int MLastX { get; set; }
public int MLastY { get; set; }

有一个方法来捕获最后一次鼠标点击的坐标

/// <summary>
/// Handles the MouseDown event of the grdSearch control. On a mousedown the click co-ordinates
///  is set.  This method is used to determine whether you have clicked on a gridrow cell in the method above
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
private void grdSearch_MouseDown(object sender, MouseEventArgs e)
{
    MLastX = e.X;
    MLastY = e.Y;
}

检查该点击是否在单元格中

//check whether you have clicked in a cell 
if (grdSearch.HitTest(MLastX, MLastY) == GridArea.Cell)
{
   //now only execute the rest
}
于 2016-09-26T07:36:55.917 回答