You could do something like this:
Child form
public string YourText { get; set; }
public TestForm()
{
InitializeComponent();
}
public void UpdateValues()
{
someLabel.Text = YourText;
}
Initiate it
var child = new TestForm {YourText = someTextBox.Text};
child.UpdateValues();
child.ShowDialog();
With this approach you don't have to change the Constructor, you could also add another constructor.
The reason for them being empty is that the properties are set after the constructor, you could Also do someting like this to add a bit of logic to your getters and setters, However, I would consider not affecting UI on properties!
private string _yourText = string.Empty;
public string YourText
{
get
{
return _yourText;
}
set
{
_yourText = value;
UpdateValues();
}
}
In this case, the UI will be updated automaticly when you set the property.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…