Re: Reverse Sorting ListView with Right-Click



You'll have to add your own code for that. It's pretty easy with some
inheritance and P/Invoke stuff. Something like this should work (inherit
ListView):

private const int WM_NOTIFY = 0x4E;
private const int NM_FIRST = 0;
private const int NM_RCLICK = NM_FIRST - 5;

[StructLayout(LayoutKind.Sequential)]
private struct NMHDR
{
public IntPtr hwndFrom;
public int idFrom;
public int code;
}

protected override void WndProc(ref System.Windows.Forms.Message m)
{
if (m.Msg == WM_NOTIFY)
{
NMHDR nm = (NMHDR) m.GetLParam(typeof(NMHDR));
if (nm.code == NM_RCLICK)
{
// TODO: Handle right click
}
}
base.WndProc(ref m);
}

/claes

"Robert W." <RobertW@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:87568A3C-8611-4A36-B266-623010171D55@xxxxxxxxxxxxxxxx
I learned how to sort a ListView by clicking on the column headers from
this:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.listview.listviewitemsorter.aspx

I'm wondering if there's a way to reverse sort it with a right-click? I
tried monitoring the MouseDown event but it didn't fire when the header
was
right-clicked.

Any ideas?

--
Robert W.
Vancouver, BC
www.mwtech.com



.