🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.delphi.winforms.controls.using
3 messages
3 total messages Started by Slagert Fri, 17 Aug 2007 19:16
How To Clear a Listbox Using an ArrayList DataSource?
#173
Author: Slagert
Date: Fri, 17 Aug 2007 19:16
12 lines
1263 bytes
How do I clear  a Listbox that uses an ArrayList for its DataSource?

If I try MyListBox.Items.Clear I get an exception telling me I can't change 
the listbox's ItemCollection if the DataSource is set.

If I try MyArrayList.Clear I see that the array is cleared but the listbox 
is not. If I then add new items to the array they do not show in the 
listbox.

So how do I clear a listbox if the datasource is set?

-Andy 
Re: How To Clear a Listbox Using an ArrayList DataSource?
#174
Author: Slagert
Date: Fri, 24 Aug 2007 16:31
12 lines
1277 bytes
Ok, I'll answer this myself since nobody seems to be listening here...

To empty a Delphi .Net listbox that uses an array for a data source just set 
the listbox's datasource property to nil. For instance if your listbox is 
named MyListbox you can use the following code to remove the items from the 
listbox.

MyListbox .DataSource := nil;

There it is, now we have the answer.

-Andy 
Re: How To Clear a Listbox Using an ArrayList DataSource?
#175
Author: Marc Rohloff TeamB
Date: Fri, 24 Aug 2007 17:43
18 lines
1892 bytes
On Fri, 24 Aug 2007 09:31:16 -0700, Slagert wrote:

> Ok, I'll answer this myself since nobody seems to be listening here...
> 
> To empty a Delphi .Net listbox that uses an array for a data source just set 
> the listbox's datasource property to nil. For instance if your listbox is 
> named MyListbox you can use the following code to remove the items from the 
> listbox.
> 
> MyListbox .DataSource := nil;
> 
> There it is, now we have the answer.

You could also set it to an empty array if it makes your code simpler.

-- 
Marc Rohloff [TeamB]
marc -at- marc rohloff -dot- com
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads