Is there a statement that will completely empty a listbox?

  • Thread starter Thread starter cj
  • Start date Start date
Hello cj,

You have GOT TO BE FREAKIN KIDDING ME! Does no one install the help files?
Does no one look in the object browser? Damn.

-Boo
 
It doesn't look like it, no.

Use a listview instead - that's got a .Clear method...
_________________________________________________________
The Grim Reaper
 
The Grim Reaper said:
It doesn't look like it, no.

Use a listview instead - that's got a .Clear method...

LOL... Try 'Me.ListView1.Items.Clear()'.
 
The OP said "completely empty".. I was going with the ListView1.Clear(),
which as you probably know clears the columns/headers as well as the items.
_________________________________________
The Grimy Raper
 
The Grim Reaper said:
The OP said "completely empty".. I was going with the ListView1.Clear(),
which as you probably know clears the columns/headers as well as the
items.

Well, the listbox control doesn't support column headers, so you do not need
to clear them.
 
Hi Cj,

If you add items into ListBox by code, you could use the following
statement to completely empty a Listbox. The following is a sample code.

listBox1.Items.Clear();

If you set the DataSource property of the ListBox to a data source, you
could set the ListBox's DataSource property null to empty the ListBox.
Below is a sample code.

listBox1.DataSource = null;

Hope this helps.

If you have anything unclear, please feel free to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
GhostInAK said:
Hello cj,

You have GOT TO BE FREAKIN KIDDING ME! Does no one install the help
files? Does no one look in the object browser? Damn.

-Boo
I'm with you, Ghost! It takes too much effort to look something up -
sometimes it even takes understanding what to look for. So much easier
to just ask.

T
 
Cj,

In addition to Oenone

In a binded listbox, set the datasource (or binding) to nothing

I hope this helps,

Cor
 
Linda,

Almost correct, I had not seen your answer while I was answering the
followup message.

However please in VB code in this newsgroup. "null" can be confusing for VB
developers.

Therefore
listBox1.Items.Clear()
and
listBox1.DataSource = Nothing

What means

Cor
 
..items.clear

ok, I'd thought it was .clear but only saw clearselected. I haven't
used listbox in years.

Thanks

listview is new to me--don't know anything about it.
 
Thanks Linda and Cor, I just needed .items.clear but I'll try to keep
the datasource=nothing in mind.
 
Back
Top