Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Winforms 防止双击行分隔符触发DoubleClick事件_Winforms_Datagridview - Fatal编程技术网

Winforms 防止双击行分隔符触发DoubleClick事件

Winforms 防止双击行分隔符触发DoubleClick事件,winforms,datagridview,Winforms,Datagridview,在rowheaders可见性设置为false且allowusertoresizerow设置为true的datagridview中,如果双击行分隔符,我需要防止触发celldoubleclick事件(当光标位于分隔符上时,行大小调整的ToubleRow可见) 谢谢我想最简单的方法是在CellDoubleClick事件本身上检查网格的点击区域;逻辑是在单击rowresizetop或rowresizebottom区域时返回,如果没有,则继续处理。有关更多详细信息,请查看以下示例: private vo

在rowheaders可见性设置为false且allowusertoresizerow设置为true的datagridview中,如果双击行分隔符,我需要防止触发celldoubleclick事件(当光标位于分隔符上时,行大小调整的ToubleRow可见)


谢谢

我想最简单的方法是在CellDoubleClick事件本身上检查网格的点击区域;逻辑是在单击rowresizetop或rowresizebottom区域时返回,如果没有,则继续处理。有关更多详细信息,请查看以下示例:

private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
    // get mouse coordinates
    Point mousePoint = dataGridView1.PointToClient(Cursor.Position);
    DataGridView.HitTestInfo hitTestInfo = dataGridView1.HitTest(mousePoint.X, mousePoint.Y);
    // need to use reflection here to get access to the typeInternal field value which is declared as internal
    FieldInfo fieldInfo = hitTestInfo.GetType().GetField("typeInternal", 
        BindingFlags.Instance | BindingFlags.NonPublic);
    string value = fieldInfo.GetValue(hitTestInfo).ToString();
    if (value.Equals("RowResizeTop") || value.Equals("RowResizeBottom"))
    {
        // one of resize areas is double clicked; stop processing here      
        return;
    }
    else
    {
        // continue normal processing of the cell double click event
    }
} 

希望这能有所帮助,关于

我想最简单的方法是在CellDoubleClick事件本身上检查网格的点击区域;逻辑是在单击rowresizetop或rowresizebottom区域时返回,如果没有,则继续处理。有关更多详细信息,请查看以下示例:

private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
    // get mouse coordinates
    Point mousePoint = dataGridView1.PointToClient(Cursor.Position);
    DataGridView.HitTestInfo hitTestInfo = dataGridView1.HitTest(mousePoint.X, mousePoint.Y);
    // need to use reflection here to get access to the typeInternal field value which is declared as internal
    FieldInfo fieldInfo = hitTestInfo.GetType().GetField("typeInternal", 
        BindingFlags.Instance | BindingFlags.NonPublic);
    string value = fieldInfo.GetValue(hitTestInfo).ToString();
    if (value.Equals("RowResizeTop") || value.Equals("RowResizeBottom"))
    {
        // one of resize areas is double clicked; stop processing here      
        return;
    }
    else
    {
        // continue normal processing of the cell double click event
    }
} 

希望这能有所帮助,因为

出于完全不同的原因,我还需要知道我是否在单击datagridview行的调整大小区域。这非常有效-谢谢!非常感谢。为什么Microsoft不能在DataGridViewHitTestType枚举中包含行和列分隔符的值?出于完全不同的原因,我还需要知道是否单击了datagridview行的调整大小区域。这非常有效-谢谢!非常感谢。为什么Microsoft不能在DataGridViewHitTestType枚举中包含行和列分隔符的值?