Strange behavior data-bound combobox

C

Crazy Cat

I am using a data-bound combobox with dropdownstyle set to
dropdownlist. Teh combobox is bound to a bindingsource which is in turn
bound to a table in my database. The table has only 4 rows and I am
using it to display geographical regions - Northeast, Southeast, West,
and Central. In the bindingsource AddNew is set to false.

Whenever I select an item from the combobox I find that the position in
the dropdown list is replaced by the value that was displayed prior to
making the new selection. For example when I start the application and
view the dropdown list I see the following

West
Central
Southeast
Northwest

with West being initially displayed in the textbox. If I select
Southeast the list changes to the following

Southeast
Central
Southeast
Northwest

and Southeast is displayed in the textbox. I can no longer select West
because it is no longer in the dropdown list !!!!

This seems like a bug to me -- or is that how the combobox is supposed
to work? I want my list to be immutable.

What am I doing wrong?

Thanks,

Crazy
 
C

Crazy Cat

Crazy said:
I am using a data-bound combobox with dropdownstyle set to
dropdownlist. Teh combobox is bound to a bindingsource which is in turn
bound to a table in my database. The table has only 4 rows and I am
using it to display geographical regions - Northeast, Southeast, West,
and Central. In the bindingsource AddNew is set to false.

Whenever I select an item from the combobox I find that the position in
the dropdown list is replaced by the value that was displayed prior to
making the new selection. For example when I start the application and
view the dropdown list I see the following

West
Central
Southeast
Northwest

with West being initially displayed in the textbox. If I select
Southeast the list changes to the following

Southeast
Central
Southeast
Northwest

and Southeast is displayed in the textbox. I can no longer select West
because it is no longer in the dropdown list !!!!

This seems like a bug to me -- or is that how the combobox is supposed
to work? I want my list to be immutable.

What am I doing wrong?

Thanks,
Sorry to respond to myself but I found the solution and wanted to share
it should anyone run into this problem. The problem was that I had set
Data Source and Data Member properties of the data-bound control,
without realizing that the Data Set Manager had set the Text property
under the Databindings properties (it's easy to miss since the Text
property is a sub property of the Databindings and is not visible until
you expand Databindings). Anyways once I set the Text subproperty to
nothing all was fine.
 
C

CMM

Seems like you have bound the "DataSource" property (which only provides the
list of items) and the Text property (which gets and updates a field in a
dataset) to the same thing. Just a quick guess. They're supposed to be
different.
 

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

Top