clearing a listbox

G

Guest

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
 
H

Herfried K. Wagner [MVP]

* "=?Utf-8?B?YW1iZXI=?= said:
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!
 
S

Scott M.

Calling clear() works for me, but you might try calling refresh after clear:

ListBox1.Items.Clear()

ListBox1.Refresh





amber said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top