How to call the event ComboBox1_SelectedIndexChanged in c #

1

How to call the event ComboBox1_SelectedIndexChanged from a function? I want to trigger the events that are programmed in the SelectedIndexChanged .

    
asked by Iluminati78 26.05.2016 в 19:56
source

2 answers

2

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

    
answered by 26.05.2016 в 21:13
1

Inside the function you could try the following:

ComboBox1_SelectedIndexChanged(null,null);

I hope I helped you. Greetings.

    
answered by 26.05.2016 в 20:59