PC Review


Reply
Thread Tools Rate Thread

Databinding combobox (repost)

 
 
Rob Oldfield
Guest
Posts: n/a
 
      13th Aug 2003
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?




 
Reply With Quote
 
 
 
 
Stephen Alpert
Guest
Posts: n/a
 
      13th Aug 2003
On Wed, 13 Aug 2003 16:28:45 +0100, "Rob Oldfield" <rob(an a in a
circle)realuk.co.uk> wrote:

>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 Removed) is encrypted with ROT13 (www.rot13.org)
 
Reply With Quote
 
Rob Oldfield
Guest
Posts: n/a
 
      14th Aug 2003

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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Wed, 13 Aug 2003 16:28:45 +0100, "Rob Oldfield" <rob(an a in a
> circle)realuk.co.uk> wrote:
>
> >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 Removed) is encrypted with ROT13 (www.rot13.org)



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataBinding to a DataView -- only getting first row [repost] Beverley Microsoft ADO .NET 4 5th Oct 2004 06:09 PM
Databinding Bible (REPOST FROM m.p.d.f.WindowsForms.Databinding) a Microsoft ADO .NET 1 16th Jul 2004 03:26 AM
DataBinding ComboBox Aaron Prohaska Microsoft Dot NET Framework Forms 1 9th Apr 2004 08:26 PM
comboBox Databinding WillieJoe Microsoft Dot NET Compact Framework 1 9th Sep 2003 05:55 PM
Databinding combobox Rob Oldfield Microsoft Dot NET Framework Forms 0 30th Jul 2003 05:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:06 PM.