Handling a double mouseclick on DGV ColumnHeaders?

I have a DataGridView in which the User is presented with a TabControl containing two TabPages. The first TabPage contains a DataGridView control which lists "Detail" records. The second TabPage contains various controls in which to edit the row of data selected from the DGV.

In order for a User to edit a row of data, they need to double-click on a specific row...when they do that, the row of data is selected and the program will populate the controls on the second TabPage and the second TabPage will then have focus.

The problem that I am having is that if the User happens to double-click on a Column Header and not a specific row of data, the DataGridView_DoubleClick event fires and makes the second TabPage have the focus...which is what the DoubleClick event is suppose to do but not when a Column Header is double-clicked on.

I thought that if a Column Header was double-clicked, the DataGridView1_ColumnHeaderMouseDoubleClick() Event would fire but it doesn't appear to be as I have set a breakpoint in that event. What's the best way to handle a Double-Click on the Column Header? I have my code below.

        Private Sub dgvEquipment_ColumnHeaderMouseDoubleClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles dgvEquipment.ColumnHeaderMouseDoubleClick
        blnColHeaderWasClicked = True
    End Sub

        Private Sub dgvEquipment_DoubleClick(sender As Object, e As EventArgs) Handles dgvEquipment.DoubleClick
            Dim row As DataGridViewRow = dgvEquipment.CurrentRow

            If blnColHeaderWasClicked Then
                blnColHeaderWasClicked = False
            End If

        Catch ex As Exception
            strErr = gfrmID & "/dgvEquipment_DoubleClick() - " & ex.Message
            MessageBox.Show(strErr, "User Notification", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

In your event  

Private Sub dgvEquipment_DoubleClick(sender As Object, e As EventArgs) Handles dgvEquipment.DoubleClick

you can check for the row number being 0 and if it is then ignore it as that's the column header row.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.