Solved

Sort list box, vb.net

Posted on 2014-11-13
1
295 Views
Last Modified: 2014-11-14
I have the following list box made with multiple columns:sortI want to be able to sort this list box by one column (any of those at display).

Question: How can I do this?

I know, I could capture Y position at mouse down (this will help me to identify when the header area is clicked). I can also capture X position if column widths doesn't change.

So mouse down even alone could help me to identify what column has been clicked on. But I have to be able either:
a. Keep the column widths fixed, or
b. Read the column widths when the list box gets filled in.

Could you possibly think of a solution for a and/or b above.

Gridview is a good option but I want something very light weight. Are there some other middle ground controls like ListView we had in vb 6.0?

Thanks.
0
Comment
Question by:Mike Eghtebas
1 Comment
 
LVL 51

Accepted Solution

by:
HainKurt earned 500 total points
ID: 40441831
ListView here
http://msdn.microsoft.com/en-us/library/system.windows.forms.listview(v=vs.110).aspx

' Sort the items in the list in ascending order.
listView1.Sorting = SortOrder.Ascending

Custom sorting
The following code example creates a form that contains a ListView control that manually sorts items when a column in the ListView control is clicked.
http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.listviewitemsorter(v=vs.110).aspx
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now