Let's say I have a customer registration form:
var frmCadCli1 = new frmCadastroCliente();
And I just called this form:
frmCadCli1.Show();
When I call this form, immediately before it is shown the Form_Load
event is triggered.
I happen to want to run a Form_Load
different for each instance of frmCadastroCliente
, for example:
private void btnConsulta_Click(object sender, EventArgs e)
{
var frmCadCli2 = new frmCadastroCliente();
}
Corresponding form load:
private void Form1_Load(object sender, EventArgs e)
{
label1.Text = "Cadastro de Clientes";
}
Then:
private void btnAltera_Click(object sender, EventArgs e)
{
var frmCadCli3 = new frmCadastroCliente();
}
Corresponding form load:
private void Form1_Load(object sender, EventArgs e)
{
label1.Text = "Alteração de Cadastro";
}
The reason I would like to run a Form_Load
different for each instance is that I would have different instances with different purposes using the same design .
In this way I could, for example, use this form as a customer registration screen, change registration, or even as a supplier register, just changing the form's properties in Form_Load