How to call the event ComboBox1_SelectedIndexChanged from a function? I want to trigger the events that are programmed in the SelectedIndexChanged .
How to call the event ComboBox1_SelectedIndexChanged from a function? I want to trigger the events that are programmed in the SelectedIndexChanged .
It is not invoked directly to the code of an event, it is not a good development practice, the reusable code should be taken to a separate function
public void ComboBox1_SelectedIndexChanged (object sender, ...)
{
FuncionalidadComun();
}
public void button1_Click(..)
{
FuncionalidadComun();
}
private void FuncionalidadComun()
{
//aqui codigo comun
}
If from two places you need to invoke shared code, you take it to another function
Inside the function you could try the following:
ComboBox1_SelectedIndexChanged(null,null);
I hope I helped you. Greetings.