Solved

Sort list box, vb.net

Posted on 2014-11-13
1
302 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

21 Experts available now in Live!

Get 1:1 Help Now