473,468 Members | 4,540 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Reverse Sorting ListView with Right-Click

I learned how to sort a ListView by clicking on the column headers from this:
http://msdn2.microsoft.com/en-us/lib...temsorter.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

May 16 '06 #1
1 3076
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." <Ro*****@discussions.microsoft.com> wrote in message
news:87**********************************@microsof t.com...
I learned how to sort a ListView by clicking on the column headers from
this:
http://msdn2.microsoft.com/en-us/lib...temsorter.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

May 17 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: rmorvay | last post by:
I have successfully integrated sorting in the listview control with the following code: Private Sub ListView_ColumnClick(ByVal sender As Object, ByVal e As...
0
by: Samuel R. Neff | last post by:
I'm impleneting a custom ListView with column sorting support and am deciding whether to reuse the Sorting property to indicate direction or create a new property. The only drawback I see is that...
19
by: Owen T. Soroke | last post by:
Using VB.NET I have a ListView with several columns. Two columns contain integer values, while the remaining contain string values. I am confused as to how I would provide functionality to...
2
by: Li Pang | last post by:
Hi, I use a listview to populate the data, and define a sorting direction with Me.ListView1.Sorting = System.Windows.Forms.SortOrder.Ascending so far no problem. As long as I add a new row...
1
by: Alex Levi | last post by:
How it is possible to sort ListView by clicking on the column when I have numeric values (as string) in the column? I tried to add numeric values into the listview, but it addes them as strings. ...
2
by: MikeY | last post by:
Hi everyone, After reading various posts I'm still scratching my head and unsure of what approach to take. I have created buttons that upon clicking, the buttons add an item name (myName) to my...
2
by: jediknight | last post by:
Hi, I have a listview which has columns of text and columns of numerical data. I need to be able to sort these columns into ascending/desending order whenever the user clicks on the column...
2
by: Steve Z. | last post by:
I am trying to implement the sorting of a ListView object by clicking on a column (using the example at:...
3
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using vs2005, .net 2 for C# windows application. One of my column on the Listview control has numericstring. Other columns are sorting correctly except this one. It seems to be sorting...
2
by: win | last post by:
The SortKey of VB6 is not in .Net. Can I still do sorting using a listview? Thanks
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.