我想最简单的方法是检查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
}
}
希望这有帮助,问候