You need to add an event to your UserControl and fire this event when a value is set and confirmed. Let's call this event
ValueSet
.
public class ValueSetEventArgs : System.EventArgs {
internal ValueSetEventArgs(string value) { this.fValue = value; }
public string FValue { get {return fValue; } }
string fValue;
}
public class MyUserControl {
public System.EventHandler<ValueSetEventArgs> ValueSet;
void SetValue(string value) {
if (this.ValueSet != null)
this.ValueSet.Invoke(this, new ValueSetEventArgs(value));
}
}
You form #1 should add an event handler to this instance of your
MyCustomControl
. This event can set the value of your label or whatever else:
class MyForm Form {
public MyForm {
InitializeComponent();
MyUserControl.ValueSet += (sender, eventArgs) => {
MyLabel.Text = eventArgs.Value;
}
}
Label MyLabel = new Label();
MyUserControl MyUserControl = new MyUserControl();
}
Problem solved.
—SA