How can I bind a custom property of a windows form to a second property?

Your form needs to implement INotifyPropertyChanged for the MyTargetProperty Example: class FooForm : Form, INotifyPropertyChanged { private int myTargetProperty; public int MyTargetProperty { get { return this. MyTargetProperty; } set { this. MyTargetProperty = value; this.

OnPropertyChanged( new PropertyChangedEventArgs("MyTargetProperty")); } } public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(PropertyChangedEventArgs e) { var evt = this. PropertyChanged; if (evt! = null) evt(this, e); } } Then you need to add the binding like this: this.DataBindings.

Add( "OtherProperty", this, "MyTargetProperty", false, DataSourceUpdateMode. Never) This will perform a one way binding. The MyTargetProperty will never be updated when the OtherProperty changes.

If you need a two way binding you change the DataSourceUpdateMode and also implement a PropertyChanged for OtherProperty.

Your form needs to implement INotifyPropertyChanged for the MyTargetProperty. Example: class FooForm : Form, INotifyPropertyChanged { private int myTargetProperty; public int MyTargetProperty { get { return this. MyTargetProperty; } set { this.

MyTargetProperty = value; this. OnPropertyChanged( new PropertyChangedEventArgs("MyTargetProperty")); } } public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(PropertyChangedEventArgs e) { var evt = this. PropertyChanged; if (evt!

= null) evt(this, e); } } Then you need to add the binding like this: this.DataBindings. Add( "OtherProperty", this, "MyTargetProperty", false, DataSourceUpdateMode. Never); This will perform a one way binding.

The MyTargetProperty will never be updated when the OtherProperty changes. If you need a two way binding you change the DataSourceUpdateMode and also implement a PropertyChanged for OtherProperty.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions