Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I insert a row in the middle of a listview?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I'd like to add a row of data into an already populated listview. I've tried the listview1.listitems.add but can't seem to get it to work properly. I need to insert the row (with several columns) in the middle of the list, not just adding new items to the list.

Thanks, Steve.
 
Steve -

I've had the same problem in the past, and after beating my head against it for a while, what I did was re-architect things a bit.

Rather than having the listview contain my data, I keep my data in a collection. The Add method in collections (unlike the Add method on the listview control) has optional parameters to insert items before or after other items. Once I've inserted the new item into the collection, I then reload the listview from scratch.

You can disable the listview before clearing/loading it and re-enable it afterwards to prevent flicker.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top