By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,201 Members | 956 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,201 IT Pros & Developers. It's quick & easy.

form activate event and listview sort

P: n/a
I have a form which contains a listview item. The form is created to view
data that is generated by interaction with a separate form.

There are buttons on the form that change the data source that is
displayed in the listview. The listview can be sorted by clicking on
columns in the listview.

When I change the data for the listview I use listview1.Clear() to clear
the listview, then rebuild the listview by adding the proper columns and
subitems.

This all works fine except that if I first sort by a column and then
change the view (which does a .Clear() on the listview, then adds columns
and subitems), I get an unhandled exception in my listview sort routine.
It is complaining about an index out of range when comparing values from
two different rows in the listview.

I'm not sure where exactly in the process this happens, but the basic
problem is this: Why is the sort routine being called at all? It should
only be called when a column is clicked, and this hasn't happened.

On a possibly related note, I use the form_activated event to detect when
the form is brought to the front so I can refresh the data in the
listview. When I trace through the execution of the code, the
form_activated event seems to occur multiple times--how come?

Thanks for any help.

Terry Brown
www.stickmansoftware.com

Dec 27 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.