471,334 Members | 1,398 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,334 software developers and data experts.

form activate event and listview sort

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

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

Dec 27 '05 #1
0 1664

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Brad | last post: by
1 post views Thread by June Homer | last post: by
7 posts views Thread by Tyler Foreman | last post: by
7 posts views Thread by Pygmalion | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.