虽然有ColumnHeaderMouseDoubleClick事件,但是其总是在DoubleClick和CellMouseDoubleClick事件之后才响应该事件。要控制该事件只能通过获取鼠标点击的位置来判断点击的区域是否是ColumnHeader,来执行相应的操作。
| 1 | private void dgvPatientList_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) |
| 2 | { |
| 3 | Point pt = this.dgvPatientList.PointToClient(Control.MousePosition); |
| 4 | DataGridView.HitTestInfo info = this.dgvPatientList.HitTest(pt.X,pt.Y); |
| 5 | |
| 6 | if (info.Type != DataGridViewHitTestType.ColumnHeader) |
| 7 | { |
| 8 | btnView_Click(sender, e); |
| 9 | |
| 10 | } |
| 11 | } |
| 12 |
浙公网安备 33010602011771号