By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,136 Members | 1,087 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,136 IT Pros & Developers. It's quick & easy.

combobox datasource dropdown problem

P: n/a
When you use a bound combobox and you set its dropdown style to "dropdown"
that allows you to enter text in the edit box. But if you enter anything
other than a value in the current bound items collection, the .text property
does not update. Furthermore, you can't easily trap an event to examine the
new value if your program assigns it programmatically as opposed to someone
typing it in and tabbing away from it. That is, TextChanged does not fire
when you programmatically assign the combobox .text property.

Even after you do the assignment, when your code has a chance to read the
combobox, it turns out that the .text value is still set to the last valid
string assigned (by binding or another assignment) EVEN THOUGH THE VISIBLE
TEXT SHOWS SOMETHING DIFFERENT. I call this a bug, but obviously, the
underlying combobox code is written to store the old value returned by
getting the .text property and not exposing the visible text.

I'm assuming this is a well-known problem. I've verified that it does not
occur if you populate a comobox manually, i.e., don't bind it.

First, does it even make sense to allow someone to enter a value (or let the
program assign a value) that is not found in the bound data or is it assumed
that the bound combobox style should be set to "dropdown list?"

Next, I saw an example where the programmer adds the newly entered value
into the list in the TextChanged event, but this won't work for me because:
a) This event doesn't fire on programmatic assignment of the .text property
b) The combobox is bound to a dataset, so items.add fails with an error
saying that this is not permitted when the control's datasource is set.

Can someone suggest a straightforward solution to capturing the assignment
of the .text property and retrieving this property (via adding it to the
items collection or some other means)?

Thanks a bunch!
Norm
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
* "Norm Katz" <nk****@yahoo.com> scripsit:
When you use a bound combobox and you set its dropdown style to "dropdown"
that allows you to enter text in the edit box. But if you enter anything
other than a value in the current bound items collection, the .text property
does not update. Furthermore, you can't easily trap an event to examine the
new value if your program assigns it programmatically as opposed to someone
typing it in and tabbing away from it. That is, TextChanged does not fire
when you programmatically assign the combobox .text property.


Windows Forms Data Binding group:

<news://news.microsoft.com/microsoft.public.dotnet.framework.windowsforms.dat abinding>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.