catching a rightclick on a listview header?

  • Thread starter Thread starter nic
  • Start date Start date
N

nic

Anyone know of a way to catch a right click on the header of a listview?
TheColumnClick event is only fired for left clicking on a header.

thanks!

nic
 
Not a .NET way but a native way
Inherit ListView, override WndProc and listen for a HDN_ITEMCLICK
notification


Public Const NM_RCLICK As Integer = -5
Public Const WM_NOTIFY As Integer = &H4E

<StructLayout(LayoutKind.Sequential)> Public Structure NMHDR
Public hwndFrom As IntPtr
Public idFrom As Integer
Public code As Integer
End Structure

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_NOTIFY Then
Dim nm As NMHDR = CType(m.GetLParam(GetType(NMHDR)), NMHDR)
If nm.code = NM_RCLICK Then
Debug.WriteLine("Right button clicked")
End If
End If
MyBase.WndProc(m)
End Sub

/claes
 
Sorry, that should be "listen for a NM_RCLICK notification"
The code is correct though

/claes
 
Back
Top