473,320 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

ComboBox, ListBox DataSource = null not work

Hi,

On form_load() I bind a combobox to a dataset and listbox to a datatable.

When I want to unbind it I call comboBox1.DataSource = null,
listBox1.DataSource = null
It unbind but the Items still persist in the comboBox and listBox. I expect
it to be empty list.

Can anyone tell me how to unbind the comboBox and automatically clear it
items?

Regards,
kids
Nov 16 '05 #1
4 22154
try it

comboBox1.DataSource = null;
comboBox.items.clear();

"kids_pro" <ki******@yahoo.com> дÈëÏûÏ¢
news:O3*************@TK2MSFTNGP12.phx.gbl...
Hi,

On form_load() I bind a combobox to a dataset and listbox to a datatable.

When I want to unbind it I call comboBox1.DataSource = null,
listBox1.DataSource = null
It unbind but the Items still persist in the comboBox and listBox. I expect it to be empty list.

Can anyone tell me how to unbind the comboBox and automatically clear it
items?

Regards,
kids

Nov 16 '05 #2
I already try but it still there.

"¼ªÈÕ¸ÂÀ*" <ji******@163.net> wrote in message
news:ux****************@TK2MSFTNGP15.phx.gbl...
try it

comboBox1.DataSource = null;
comboBox.items.clear();

"kids_pro" <ki******@yahoo.com> дÈëÏûÏ¢
news:O3*************@TK2MSFTNGP12.phx.gbl...
Hi,

On form_load() I bind a combobox to a dataset and listbox to a datatable.
When I want to unbind it I call comboBox1.DataSource = null,
listBox1.DataSource = null
It unbind but the Items still persist in the comboBox and listBox. I

expect
it to be empty list.

Can anyone tell me how to unbind the comboBox and automatically clear it
items?

Regards,
kids


Nov 16 '05 #3
Hi,

I have no experiences with DataBinding but i can recommend
to try:

comboBox1.DataSource = null;
comboBox1.DataBindings.Clear();

Regards

Marcin
I already try but it still there.

"¼ªÈÕ¸ÂÀ*" <ji******@163.net> wrote in message
news:ux****************@TK2MSFTNGP15.phx.gbl...
try it

comboBox1.DataSource = null;
comboBox.items.clear();

"kids_pro" <ki******@yahoo.com> дÈëÏûÏ¢
news:O3*************@TK2MSFTNGP12.phx.gbl...
Hi,

On form_load() I bind a combobox to a dataset and listbox to a
datatable.
When I want to unbind it I call comboBox1.DataSource = null,
listBox1.DataSource = null
It unbind but the Items still persist in the comboBox and listBox. I


expect
it to be empty list.

Can anyone tell me how to unbind the comboBox and automatically clear it
items?

Regards,
kids



Nov 16 '05 #4
Hi,

Cause they are still in the control, the binding in web do not work the
same as in windows, what you can do is this:

Set the datasource= null
Call listbox.DataBind()
this should delete all
opposite what you can do if the above does not work ( very unlikely ) is
bind it to an empty collection/array, etc

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"kids_pro" <ki******@yahoo.com> wrote in message
news:O3*************@TK2MSFTNGP12.phx.gbl...
Hi,

On form_load() I bind a combobox to a dataset and listbox to a datatable.

When I want to unbind it I call comboBox1.DataSource = null,
listBox1.DataSource = null
It unbind but the Items still persist in the comboBox and listBox. I expect it to be empty list.

Can anyone tell me how to unbind the comboBox and automatically clear it
items?

Regards,
kids

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Irwin M. Fletcher | last post by:
ListBox DataSource DisplayMember Property Problems in C# I have a (single select) listbox with data and when I click on the list I can't get the right text selected. My listbox is setup...
0
by: Jesse Martinez | last post by:
My problem occurs when I use an ArrayList as a ListBox.DataSource. When the ArrayList attached to the Listbox is not empty the Listbox behave normal without problem, but if I remove all items...
1
by: Zoury | last post by:
Hi there! :O) I have a WebService that contains the following struct definition. this struct is defined right after the WebService class, ie : //*** namespace mynamespace { public class...
1
by: COHENMARVIN | last post by:
I am trying to display the contents of a directory in a listbox. I manage to get an array of fileInfo objects, and when I print them out they indeed contain several file names. But when I do...
1
by: Alex Stevens | last post by:
Hi All, I've come across something which I think is a bug in the windows forms combobox and listboxes. I have a simple form which retrieves a datatable, and then set the datasource of a...
9
by: Don | last post by:
Is there any way to detect when an item has been added to the Items collection of a combobox or listbox? I am inheriting a Combobox and want to validate items before they are added to the...
7
by: Hardik Shah | last post by:
Hi, Generaly to populate combobox , I use following command :- Combobox1.datasource = dataset.tablename combobox1.displaymember = fieldname1 combobox1.valuemember = fieldname2 As I don't...
1
by: WhiteWizard | last post by:
First my apologies, this may be longer than the normal question. I have a windows app (.NET 2.0, VS2005), and I've written a user control that will allow the user to "drag and drop" a directory...
2
by: =?Utf-8?B?U3RlcGhlbiBSaXRjaGll?= | last post by:
Hi NET1.1 / Winforms I have a listbox that I am binding to a table via the DataSource property. However I want to be able to programmatically select values in this listbox so I am using the...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.