That function is an event handler: a function that gets executed as a response to an event, in this case a user event: the user clicked a button.
If you need to execute the very same action without being triggered with an event, the correct approach is move the code that performs the action to a separate method
private void ExecuteMyAction()
{
// Do stuff
}
private void button_Click(object sender, EventArgs e)
{
ExecuteMyAction()
}
And then you can call safely that method in your constructor
public class MyClass
{
public MyClass()
{
ExecuteMyAction();
}
}
Actually it is a better to keep the code in a handler as lean as possible and move the code that performs that action to another method. In the handler you just need to gather the information needed to perform an action that it is only available when the event is processed and then pass that information to another part of the system that is in charge of processing that information.
For example, if you need the user to input a name in a Textbox when the user clicks a button, the button_click handler should only get the string from the text box and call a method that saves that information, passing the string as a parameter.
That way you reduce coupling by keeping separated the code that performs the action (business code) from the code that commands the action to be performed (which is boilerplate code that depends on the framework you use)