468,268 Members | 1,703 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,268 developers. It's quick & easy.

clearing a listbox

Hello
I'm keeping this list busy! :
Okay, now I'm trying to clear a listbox
The way I have it set up, the user can either enter a value into a textbox, then hit a button, and 1 specific record is shown in the listbox. Or, the user can just hit the button (leaving the textbox blank) and all possible records are retrieved and are displayed in the listbox. These methods work great
But, when I want to switch between the two...for example, if I retrieve all records, then enter a value to specify one, I need the listbox to clear, then just show the single selected item.
And, if a user enters a value - the listbox only shows this value, but if they enters another value, the original value stays there, it won't replace itself with the new value
The code that I am using is

listbox.datasource = Nothin
listbox.items.clear(

This isn't working for me...

Thanks in advance
Ambe

Nov 20 '05 #1
2 8038
* "=?Utf-8?B?YW1iZXI=?=" <an*******@discussions.microsoft.com> scripsit:
I'm keeping this list busy! :)


No problem, you are welcome. Nevertheless, please break lines after a
certain number of characters (~76), some newsreaders do not wrap long
lines automatically and the users (including me) will have to scroll
horizontally to read your message. Thank you!

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>
Website Address Changed!
Nov 20 '05 #2
Calling clear() works for me, but you might try calling refresh after clear:

ListBox1.Items.Clear()

ListBox1.Refresh

"amber" <an*******@discussions.microsoft.com> wrote in message
news:27**********************************@microsof t.com...
Hello.
I'm keeping this list busy! :)
Okay, now I'm trying to clear a listbox.
The way I have it set up, the user can either enter a value into a textbox, then hit a button, and 1 specific record is shown in the listbox.
Or, the user can just hit the button (leaving the textbox blank) and all
possible records are retrieved and are displayed in the listbox. These
methods work great. But, when I want to switch between the two...for example, if I retrieve all records, then enter a value to specify one, I need the listbox to clear,
then just show the single selected item. And, if a user enters a value - the listbox only shows this value, but if they enters another value, the original value stays there, it won't replace
itself with the new value. The code that I am using is:

listbox.datasource = Nothing
listbox.items.clear()

This isn't working for me....

Thanks in advance!
Amber

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

17 posts views Thread by amber | last post: by
1 post views Thread by nazir.atif | last post: by
2 posts views Thread by John | last post: by
3 posts views Thread by Angel Blue01 | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.