I have a DataGridView in a Windows Form. I want to handle double click events on each cell to display a detail form related to that record. Unfortunately, the double click event is executed when you double click on column headers. What should I do?
You should check the RowIndex and ColumnIndex property of the event arguments. If one of them is negative, it means that either a row header or a column header is clicked, you should ignore that event.
5
votes
What event are you handling? Ideally you should handle the CellDoubleClick or the CellMouseDoubleClick events and opening your details form in that handler. The latter event will catch a Double click using any of the mouse buttons (the button can be queried using the MouseEventArgs.Button property.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkRead more