Sorted ListView throws exception

G

Guest

Hi. I subclassed a ListView to give it the capability to sort by a column when the column header is clicked and it works fine. The problem is when the listview gets refreshed, all items are cleared and then read from the database and the listview is repopulated. Here it throws an exception when the 2nd item is added to the listview, apparently because it tries to compare it with the first to sort them out. Is there an easy way to sort a listview? It used to be built in VB6. I appreciate any help about this or information

Thanks in advance
 
H

Herfried K. Wagner [MVP]

* "=?Utf-8?B?UmljaGFyZA==?= said:
Hi. I subclassed a ListView to give it the capability to sort by a
column when the column header is clicked and it works fine. The problem
is when the listview gets refreshed, all items are cleared and then read
from the database and the listview is repopulated. Here it throws an
exception when the 2nd item is added to the listview, apparently because
it tries to compare it with the first to sort them out. Is there an easy
way to sort a listview? It used to be built in VB6. I appreciate any
help about this or information.

What exception?
 
G

Guest

Richard

During the repopulation set the column to sort by to Zero. When you re-add items one by one the sub-items don't exist until you create them. After you repopulate the list then reset the column to sort by to the desired column

Eri

----- Richard wrote: ----

Hi. I subclassed a ListView to give it the capability to sort by a column when the column header is clicked and it works fine. The problem is when the listview gets refreshed, all items are cleared and then read from the database and the listview is repopulated. Here it throws an exception when the 2nd item is added to the listview, apparently because it tries to compare it with the first to sort them out. Is there an easy way to sort a listview? It used to be built in VB6. I appreciate any help about this or information

Thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top