O'Reilly logo

Developing Microsoft® .NET Controls with Microsoft Visual Basic® .NET by John Connell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sorting the ListView Control

A ListView control wouldn’t be very useful if you couldn’t sort its columns. Luckily, you can set the Sorting property of a ListView control to either Ascending or Descending.

Unfortunately, this setting sorts only the first column. For example, setting Sorting to Descending doesn’t let you resort in ascending order. Not only that, but if you drag the second column, which contains the values of each property, to the first column, the control still remains sorted in descending order on the first column. Although this behavior is a bit limiting, you can change it—by writing a little code.

First, set the Sorting property of the ListView control to None; leaving it as either Ascending or Descending will override anything ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required