Posted By: jogisarge | Feb 18th @ 1:05 PM
page 1 of 1
Comments: 3 | Views: 673
 

Hi,

i have a class "user" that implements INotifyPropertyChanged.
with databinding i bind a objekt user1 to textboxes on a winform.

If i change the properties from user1, the textboxes will be updated.

Now i have a function that returns an objekt(user).
user1 = getuser(); -> no changes in the textbox.
with debugging i see, that the setter was not called.

How can i get this done ?
i want to see the returned data in my textboxes.

bye jo

ZippyV
ZippyV
Fired Up
The best solution for your problem is to use a bindingsource. During design-time you can set the datasource to your User class and bind all the textboxes to the appropriate User class properties. During runtime you assign your user class to the BindingSource.Datasource property and all fields get automatically updated.
With a bindingsource you don't need to implement the INotifyPropertyChanged on your User class.
Alternatively, you could reset the datasource of the textbox when the user reference gets changed.
This description is lacking.  Why would a function returning a User modify the UI?  You're bound to a specific object instance, and the UI is only going to update for changes to that instance.  And I'm not sure what ZippyV was talking about either... databinding will NOT auto-update without some sort of change notification (INotifyPropertyChanged and DependencyProperty).
page 1 of 1
Comments: 3 | Views: 673
Microsoft Communities