Hi,

Is there a better way to remove items from the Microsoft listview 6.0
activex control.

Our current code is, but it takes a long time if the listview has 10,000
items etc.

With This.Listview

For a = .ListItems.Count To 1 Step - 1

If .ListItems(a).Selected

.Listitems.Remove(.ListItems(a).Index)

ENDIF

EndFor

EndWith


Thanks
Tristan

Re: Is there a quicker way to remove selected items from MS listview Activex? by andrewgrandison

andrewgrandison
Thu Jun 08 09:38:09 CDT 2006

Try .ListItems.Clear()

Tristan wrote:
> Hi,
>
> Is there a better way to remove items from the Microsoft listview 6.0
> activex control.
>
> Our current code is, but it takes a long time if the listview has 10,000
> items etc.
>
> With This.Listview
>
> For a = .ListItems.Count To 1 Step - 1
>
> If .ListItems(a).Selected
>
> .Listitems.Remove(.ListItems(a).Index)
>
> ENDIF
>
> EndFor
>
> EndWith
>
>
> Thanks
> Tristan


Re: Is there a quicker way to remove selected items from MS listview Activex? by Tristan

Tristan
Thu Jun 08 15:11:24 CDT 2006

I only want to remove the items that are selected though.

Currently if I select just 4 items out of 11,000 it has to scan all 11,000
to find just the 4 that are selected. Very slow.



<andrewgrandison@hotmail.com> wrote in message
news:1149777489.056085.52450@y43g2000cwc.googlegroups.com...
> Try .ListItems.Clear()
>
> Tristan wrote:
>> Hi,
>>
>> Is there a better way to remove items from the Microsoft listview 6.0
>> activex control.
>>
>> Our current code is, but it takes a long time if the listview has 10,000
>> items etc.
>>
>> With This.Listview
>>
>> For a = .ListItems.Count To 1 Step - 1
>>
>> If .ListItems(a).Selected
>>
>> .Listitems.Remove(.ListItems(a).Index)
>>
>> ENDIF
>>
>> EndFor
>>
>> EndWith
>>
>>
>> Thanks
>> Tristan
>



Re: Is there a quicker way to remove selected items from MS listview by Bernhard

Bernhard
Fri Jun 09 03:29:37 CDT 2006

Hi Tristan,

> Currently if I select just 4 items out of 11,000 it has to scan all 11,000
> to find just the 4 that are selected. Very slow.
Maybe you don't use multi-select and delete those entries at once when the user
selects them. Then you don't need the loop.

But, basically, having more than some few hundred entries in a listbox is not a
good idea, nether for the user nor for performance.
Maybe you use a grid instead of the listbox. Put an extra column into the grid
with a checkbox for deleting if you don't like the native delete column of the grid.

Regards
Bernhard Sander

Re: Is there a quicker way to remove selected items from MS listview Activex? by Gene

Gene
Fri Jun 09 12:46:09 CDT 2006

On Fri, 09 Jun 2006 10:29:37 +0200, Bernhard Sander
<fuchs@individsoft.de> wrote:

>> Currently if I select just 4 items out of 11,000 it has to scan all 11,000
>> to find just the 4 that are selected. Very slow.
>Maybe you don't use multi-select and delete those entries at once when the user
>selects them. Then you don't need the loop.
>
>But, basically, having more than some few hundred entries in a listbox is not a
>good idea, nether for the user nor for performance.
>Maybe you use a grid instead of the listbox. Put an extra column into the grid
>with a checkbox for deleting if you don't like the native delete column of the grid.

I agree, except read "dozen" for "hundred". (Even a U.S. state
list is overly long for comfort in use.)

Sincerely,

Gene Wirchenko


Re: Is there a quicker way to remove selected items from MS listview Activex? by Imaginecorp

Imaginecorp
Fri Jun 09 21:11:38 CDT 2006

Hello Tristan:
It depends on how you are populating the list box. The method you have
listed is for Rowsourcetype = 0. Right?
One way to speed this up is to populate the list with a table (set Deleted
On in either the forms Load or the DE's BeforeOpenTables) or View (with
Deleted = .f. ). and Listbox's rowsourcetype = 6 - fields. this way the
listbox will always be on the right record.
When the user selects a record to be deleted, (Ask the user to double click
the record to delete) in the doubleclick method of the listbox do a simple
Delete next 1. Once done with all the deletes, do a simple Requery() on the
listbox
That's it. It is much faster than a For..EndFor.
Like you I prefer Listboxes to Grids which are a PIA. 10,000 records is
chicken, We have gone as high as 160,000 records for a major client and it
works fast and efficient. But its a little risky and a LOT of considerations
have to be built in and if the VFP capacities change we are screwed.
Good Luck
Mohammed
www.imaginecorp.com/whatwedo.htm


"Tristan" <test@somebody.com> wrote in message
news:%23GZ2u$siGHA.1640@TK2MSFTNGP02.phx.gbl...
> Hi,
>
> Is there a better way to remove items from the Microsoft listview 6.0
> activex control.
>
> Our current code is, but it takes a long time if the listview has 10,000
> items etc.
>
> With This.Listview
>
> For a = .ListItems.Count To 1 Step - 1
>
> If .ListItems(a).Selected
>
> .Listitems.Remove(.ListItems(a).Index)
>
> ENDIF
>
> EndFor
>
> EndWith
>
>
> Thanks
> Tristan
>
>



Re: Is there a quicker way to remove selected items from MS listview Activex? by Imaginecorp

Imaginecorp
Fri Jun 09 22:49:39 CDT 2006

I just re-read your post;
I do not know how the below code will work with an active x control. Never
used active x and never will, they are crap. use the VFP listbox ...
Mohammed

"Imaginecorp" <imaginecorp@msn.com> wrote in message
news:upXl1MDjGHA.4776@TK2MSFTNGP05.phx.gbl...
> Hello Tristan:
> It depends on how you are populating the list box. The method you have
> listed is for Rowsourcetype = 0. Right?
> One way to speed this up is to populate the list with a table (set Deleted
> On in either the forms Load or the DE's BeforeOpenTables) or View (with
> Deleted = .f. ). and Listbox's rowsourcetype = 6 - fields. this way the
> listbox will always be on the right record.
> When the user selects a record to be deleted, (Ask the user to double
> click the record to delete) in the doubleclick method of the listbox do a
> simple Delete next 1. Once done with all the deletes, do a simple
> Requery() on the listbox
> That's it. It is much faster than a For..EndFor.
> Like you I prefer Listboxes to Grids which are a PIA. 10,000 records is
> chicken, We have gone as high as 160,000 records for a major client and it
> works fast and efficient. But its a little risky and a LOT of
> considerations have to be built in and if the VFP capacities change we are
> screwed.
> Good Luck
> Mohammed
> www.imaginecorp.com/whatwedo.htm
>
>
> "Tristan" <test@somebody.com> wrote in message
> news:%23GZ2u$siGHA.1640@TK2MSFTNGP02.phx.gbl...
>> Hi,
>>
>> Is there a better way to remove items from the Microsoft listview 6.0
>> activex control.
>>
>> Our current code is, but it takes a long time if the listview has 10,000
>> items etc.
>>
>> With This.Listview
>>
>> For a = .ListItems.Count To 1 Step - 1
>>
>> If .ListItems(a).Selected
>>
>> .Listitems.Remove(.ListItems(a).Index)
>>
>> ENDIF
>>
>> EndFor
>>
>> EndWith
>>
>>
>> Thanks
>> Tristan
>>
>>
>
>