Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

button.PerformClick(); not working in Form Load

I'm calling a button click in the form_load like this:

public void Form1_Load(object s, EventArgs e)
{
    button.PerformClick();
}

But upon loading the button does not get clicked, what am I doing wrong?

like image 631
Intecpsp Avatar asked Oct 10 '13 15:10

Intecpsp


1 Answers

You can write whatever you want to do inside of click in another function and call that from inside the click handler or programmatically like this -

public void Form1_Load(object s, EventArgs e)
    {
        //button.PerformClick();
        PerformClickAction();
    }

void button_click(object sender,EventArgs e) 
{
    PerformClickAction();
}

void PerformClickAction()
{
    // Write what you need to do on click
}
like image 181
Vandesh Avatar answered Sep 25 '22 01:09

Vandesh