Dailycode.info

Short solution for short problems

Binding doesn't track (pick up) the change if you programatically edit a control.

I'm working on a windows forms application that uses binding to update the contents of the controls. Works like a charm.
When the form got a little more complicated and controls where addedd dynamically, it got a little tricky.
When I changed the value of the controls programatically, the change was not picked up by the bindings. I didn't had to look very long for a solution.
I just added a .Focus or a .Select and then the binding picks up the change.
By example:
 
txtVersion.Text = versionNum.ToString
txtVersion.Select()
or
txtVersion.Text = versionNum.ToString
txtVersion.Focus()