Removing all rows from ListView (1 Viewer)

skunk711

Registered User.
Local time
Today, 19:01
Joined
Jun 19, 2002
Messages
24
Hi,

I have a ListView activeX control on my form and I am looking for a better way of removing all of the rows from my ListView control than what I am currently using.

At the moment I am just ittirating through all of the rows and deleting them until I get to the end of the list. This works, however when the listview gets quite large, this takes a long time to complete.

Any ideas?

Thanks
 

FoFa

Registered User.
Local time
Today, 13:01
Joined
Jan 29, 2003
Messages
3,672
Does the list view have a CLEAR method like the tree view to empty the whole thing at once?
 

skunk711

Registered User.
Local time
Today, 19:01
Joined
Jun 19, 2002
Messages
24
Thanks for the reply!

I had tried that previously and i had obviously used the wrong syntax. Your post made me try it again using:
lvOrderDetails.listitems.clear()
and it worked like a charm.

I have another thing you may know something about, but I'm not so sure there is a better solution to what I am currently using.

When populating the listView with listItems i open the appropriate recordset and loop through it adding each record.

This is a little slow when dealing with larger recordsets. You wouldn't happen to know of a better way?


Again thanks for helping me out.
 

FoFa

Registered User.
Local time
Today, 13:01
Joined
Jan 29, 2003
Messages
3,672
Basing the Listbox on it's own query is faster (but large DS always take awhile). have you tried rather than populating it from a VB loop, maybe either basing it on a query, or generating the query in VB and setting the (sql?) property with the proper SQL and then enable & requery the control? I have done that with a combo box where it had none selective SQL, and I generated the SQL in VB and then set the (sql?) property and requeried the control. Maybe it is datasource property (getting old I guess, CRS syndrome)
 

skunk711

Registered User.
Local time
Today, 19:01
Joined
Jun 19, 2002
Messages
24
yeah, I was hoping when i first decided to imlpement a listView that it would be a matter of assigning a query as the datasource.

However, I quickly found out that although they are great for having users resize columns, change column orders and sort by columns to find what they want, the object severely lacks any real easy methods to implement in a DB.

So I guess the answer to your reply is that I haven't seen any place or method that allows you to assign a query to a listView, although you can do it quite easily using a listBox. I was originally using a listBox, but listViews are way more user friendly when searching for information.
 

danikuper

Registered User.
Local time
Today, 14:01
Joined
Feb 6, 2003
Messages
147
How did you clear your listview items? I'm having trouble with that. By the way, my listview is based on a SQL query to populate the rows.

thanks!
daniel
 

skunk711

Registered User.
Local time
Today, 19:01
Joined
Jun 19, 2002
Messages
24
[YourListControl].listview.clear

that should clear the items.
 

danikuper

Registered User.
Local time
Today, 14:01
Joined
Feb 6, 2003
Messages
147
How would I use that if I wanted a command button on my form to perform that action?

thanks in advance!
daniel
 

Users who are viewing this thread

Top Bottom