Databinding combobox (repost)

  • Thread starter Thread starter Rob Oldfield
  • Start date Start date
R

Rob Oldfield

I have a windows form app that is bound to a dataview. If I add a combobox
(with the default style of dropdown) and bind its text property to a field
then everything is fine. If I now change the DropDownStyle to DropDownList
then the binding no longer works (data from the back end SQL doesn't get
displayed and if I select something in the combo then the update writes a
null value back).

I've tried binding to SelectedItem instead but that also doesn't work.

Anyone come up with a solution to this one?
 
I have a windows form app that is bound to a dataview. If I add a combobox
(with the default style of dropdown) and bind its text property to a field
then everything is fine. If I now change the DropDownStyle to DropDownList
then the binding no longer works (data from the back end SQL doesn't get
displayed and if I select something in the combo then the update writes a
null value back).

I've tried binding to SelectedItem instead but that also doesn't work.

I found the combobox didn't fire the currencymanager change events so I added a
SelectedItemChanged event to the combo box:

private void State_Changed(object sender, System.EventArgs e)
{
if( bmb != null && UIActive )
// UIActive means user is changing it
{
String s = (string)State.Items[State.SelectedIndex]; // new val
dt.Rows[bmb.Position]["State"] = s; // force column change?
}
}

I was bound to the "state" column in the dataset...

/steveA
my email (e-mail address removed) is encrypted with ROT13 (www.rot13.org)
 
Yes. That's roughly how I'm getting around it at the moment. I was hoping
for something a little more sensible though.

Thanks for the idea though.


Stephen Alpert said:
I have a windows form app that is bound to a dataview. If I add a combobox
(with the default style of dropdown) and bind its text property to a field
then everything is fine. If I now change the DropDownStyle to DropDownList
then the binding no longer works (data from the back end SQL doesn't get
displayed and if I select something in the combo then the update writes a
null value back).

I've tried binding to SelectedItem instead but that also doesn't work.

I found the combobox didn't fire the currencymanager change events so I added a
SelectedItemChanged event to the combo box:

private void State_Changed(object sender, System.EventArgs e)
{
if( bmb != null && UIActive )
// UIActive means user is changing it
{
String s = (string)State.Items[State.SelectedIndex]; // new val
dt.Rows[bmb.Position]["State"] = s; // force column change?
}
}

I was bound to the "state" column in the dataset...

/steveA
my email (e-mail address removed) is encrypted with ROT13 (www.rot13.org)
 
Back
Top