473,387 Members | 1,440 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,387 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 22178
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.