[Solved] Button enabling not working correctly [closed]


The Load Event is intended to get executed one time, and that’s just before the form is displayed on the screen. Usually this event is where you would do some kind of one time initialization.

What you need to do instead is put that code into a function:

private void UpdateButton()
{
    if (clicks > 5)
        button1.Enabled = true;
    else button1.Enabled = false;

    // This function can be reduced to one line of code:
    // button1.Enabled = clicks > 5;
}

Then you need to call this function at the end of your button1_click function, timer1_tick function, mousedown function and your timer1_tick_1 functions. Basically, into any function where the clicks variable can change.

1

solved Button enabling not working correctly [closed]