Solved

Sort list box, vb.net

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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