Fake
Fake

Reputation: 498

VB.NET Databound ComboBox need to force update in datasource when selection changes

I have a combobox where the SelectedValue on the combo is bound to a property on a business object.

Everything works fine, but the property that's bound to the SelectedValue on the combo only gets updated when the focus leaves the control. I understand that the property doesn't get updated until the control is validated (loses focus), but I need it to update the datasource as soon as the dropdown is closed.

I know I could probably leave focus from the control on the DropDownClosed event but I'd prefer something a little less kludgy.

What's the best way to immediately update my datasource when the dropdown is closed?

Upvotes: 0

Views: 4343

Answers (2)

Harold
Harold

Reputation: 1166

The way I'd do it is to set (in the events) the OnUpdate of the combo box and put in the VB.net

Me.<business object>.Requery

Upvotes: 0

lya
lya

Reputation: 36

Set the DataSourceUpdateMode to OnPropertyChanged. Here is similar problem:

[http://social.msdn.microsoft.com/Forums/en/winformsdatacontrols/thread/bc39342b-d9b5-4ad0-bd35-073869ccf8be][1]

Upvotes: 2

Related Questions