all groups > dotnet windows forms databinding > may 2006 >
You're in the

dotnet windows forms databinding

group:

combobox datasource


combobox datasource Alejandro González
5/25/2006 3:48:13 PM
dotnet windows forms databinding:
Hi

I have a combobox binded to a Datatable
something like

combo.DataSource = dt.DefaultView;
combo.DisplayMember = "descField";
combo.ValueMember = "valueField";

it works fine.
Now if I update the datatable I want the combo to reflect those changes.

I'm trying to rebind the combo doing the same 3 lines but it doesn't work,
(the second time the is run then it does the 1st update)

Any help?
thanks

RE: combobox datasource JT
5/30/2006 8:45:01 PM
Hi,
Try binding the selected value of your combobox the column in the datatable
whose changes you want reflected in your control.

ComboBox1.DataBindings.Add _
(New Binding("SelectedValue", myDataSet,
"myDataTable.myDataColumnName"))


Also, when binding a combobox, set the display and value members BEFORE
setting the dataSource. This prevents a firing of the selectedIndex changed
event and gives a performance boost.

JT

--
John


[quoted text, click to view]
AddThis Social Bookmark Button