Winforms databinding prob with combobox and newly created object

Winforms databinding prob with combobox and newly created object

Old forum URL:

vschaak posted on Monday, March 08, 2010

Hi @all,

I know, winforms is an outdated technology, but I've got to struggle with it.

My object is presented on a form with one of it's props beeing shown through a combobox. So far so good. When showing already db-persisted objects, all goes fine and it shows the correct values (quite not until I first bound the object and then the combobox's list, of course).

Trouble starts, when I create a new object. While there is a value choosen in the box, the objects property remains emptyAngry

What do I have to do to REALLY bind the property?

Thanks for your time


ajj3085 replied on Monday, March 08, 2010

I think you have to do it the other way around; bind the ComboBox's list items first, then bind your business object. 

JonnyBee replied on Monday, March 08, 2010


If you drag a combox from the datasources windows the WinForms designer will create a databinding on the Text property.  But that's usually not what you want to do with a BO property and using a NameValueList of valid choises.

I'd recommend to drag a ComboBox from from the Toolbox and then use the ComboBox Tasks to configure databinding.And - then make sure to set the combobox listsource before you set the datasource for your BO and make sure to unbind in the opposite order.

Finally - download the DataBinding FAQDataGridView FAQ and Designer FAQ from These FAQ are essential if you are going to be successful with Windows Forms Databinding. I also recommend to use the Windows Forms FAQ on the same site.


mbblum replied on Monday, March 08, 2010

One more detail, usually the BO property gets bound to the combo's .Value, not the .Text. There are exceptions, but typically the Value is saved to the BO and db, not the human readable Name.

vschaak replied on Wednesday, March 10, 2010


thank you for your input. I've got to admit that I feel somehow sheepish about the real reason: the combobox is the last control in tab order and pressing 'save' just after choosing a value demands some form-validation, otherwise you'll see a selected value, but it isn't really written to the datasourceEmbarrassed

So my $/€ into the kitty...

Best wishes


tiago replied on Wednesday, March 10, 2010

This is a recurring question as PTracker doesn't include an example of combobox binding. Does anyone have a small sample to post?

Copyright (c) Marimer LLC