I am trying to retrieve the column name that is relative to the column header that is clicked. My code is
Private Sub grd_ColumnHeaderMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles grd.ColumnHeaderMouseClick
Dim hit As DataGridView.HitTestInfo = grd.HitTest(e.X, e.Y)
If hit.Type = DataGridViewHitTestType.ColumnHeader Then
sColumnHeaderClicked = grd.Columns(hit.ColumnX).Name
End If
End Sub
The problem is that the values of the hit.ColumnX and hit.ColumnIndex never change. I would have thought that these would change depending on which header was clicked.
Can anyone help or enlighten me on this?
TIA