I try to understand why i can't invite event in the last line of constructor? Does the event "formload" occur after construction ends?
public Form1()
{
InitializeComponent();
button1.Text = "a";
button1.PerformClick();
}
private void button1_Click(object sender, EventArgs e)
{
button1.Text = "b";
}
This behavior is because if controls are built on the windows messages, which only works if the form instance exists and has a handle, which is not while it is still built.
The form must be open to be sure that the controls are working properly.
And it's not best practise to raise event on your constructor
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With