User Tools

Site Tools


winforms_databinding_sample

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Last revisionBoth sides next revision
winforms_databinding_sample [2018/07/29 05:12] wolfgangriedmannwinforms_databinding_sample [2018/07/29 05:21] wolfgangriedmann
Line 5: Line 5:
  
 As usual, it requires at least one line of code for every field: As usual, it requires at least one line of code for every field:
-<code>oTextBox:Bindings:Add( "Text", oViewModel, "PropertyName" )</code>+<code visualfoxpro>oTextBox:Bindings:Add( "Text", oViewModel, "PropertyName" )</code>
 where ''Text'' stands for the property of the TextBox on which the ViewModel field has to be bound, and ''FieldName'' stands for the name of the property in the ViewModel that contains the desired value. where ''Text'' stands for the property of the TextBox on which the ViewModel field has to be bound, and ''FieldName'' stands for the name of the property in the ViewModel that contains the desired value.
  
 It is very easy to implement name based binding in WinForms. You need a similar method of ther following in your window: It is very easy to implement name based binding in WinForms. You need a similar method of ther following in your window:
-<code>method Use( oViewModel as INotifyPropertyChanged ) as void +<code visualfoxpro>method Use( oViewModel as INotifyPropertyChanged ) as void 
 local oControls as System.Windows.Forms.Control.ControlCollection local oControls as System.Windows.Forms.Control.ControlCollection
 local oTextBox as TextBox local oTextBox as TextBox
Line 25: Line 25:
 return</code> return</code>
 and then you can combine your form (or View as in MVVM) with a simple statement: and then you can combine your form (or View as in MVVM) with a simple statement:
-<code>oForm:Use( oViewModel )</code>+<code visualfoxpro>oForm:Use( oViewModel )</code>
 Of course you should enhance your method to implement databinding also for the other types of controls you use, and you should put them in your windows base class from which all your forms/Views will be inherited. Of course you should enhance your method to implement databinding also for the other types of controls you use, and you should put them in your windows base class from which all your forms/Views will be inherited.
  
winforms_databinding_sample.txt · Last modified: 2018/07/29 05:28 by wolfgangriedmann