Listview Sorting In VB 2008 Issue <===

TeachMe

Member
Joined
Jun 27, 2012
Messages
16
Programming Experience
Beginner
I'm trying to make the listview sort the green "Yes!" to the top via a column "Click:" option and then the red "No" will be sorted to the bottom. We will need to make sure that the subitems will stay together.
Here's an example of what I'm trying to accomplish:
visualbasicinquirylistv.png

I would appreciate a code example if you can. Thanks.
 
As explained in ListView.ListViewItemSorter Property (System.Windows.Forms) help page you have to write a class than implements IComparer and assign an instance of that to ListViewItemSorter property. The IComparer.Compare method compares two ListViewItem objects x and y, for example like this:
            Dim a = CType(x, ListViewItem).SubItems(1).Text
            Dim b = CType(y, ListViewItem).SubItems(1).Text
            Return b.CompareTo(a)
 
Back
Top