ListView Control and Custom Sorting
I have a ListView control displaying data from a database. The Primay Key
of the table is set as "Key" in the ListView control.
It is known that a ListView control sorts data by setting the SortKey and
Sorted properties, always in a "text" fashion. The following MSDN KB articles
explains how to sort data when the column contains DATE data using the LVM_SORTITEM
message and custom compare function.
KB: Q170884. HOWTO: Sort a ListView Control by Date
Howver, once I sort the listview the relationship between the "Index" and
the "Key" is out of sync. I was looking for a way to get the "KEY" for the
selected item. If I use the normal sorting I could simply get it using:
If the listview control is sorted by sending LVM_SORTITEM message, however,
the returned key might from a different row.
The solution I have got so far working is by storing the Key as a hiden column,
geting the Index of the Selected Item and retrieving the text of the hiden
key column, all by sending LVM_xxxx messages. Even to delete the current
Has anyone has solved this problem in a simpler way from VB???
I appreciate your time for reading this and sharing your experience on this
Software Engineer, MCP
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL