HanifCs
HanifCs

Reputation: 119

Multiple Buttons in One Handler Not Working Properly

I am working on project in which I have Multiple buttons.
I want to Use only One Handler Button for multiple clicks.
I have the following code for such Button Next but it not working properly

private void ButtonNext_Click(object sender, EventArgs e)
{
    if (fFirst.Enabled == true)
    {
        fFirst.Hide();
        lectureSecondToolStripMenuItem_Click(sender, e);
    }
    else if (fSecond.Enabled == true)
    {
        fSecond.Hide();
        lectureThirdToolStripMenuItem_Click(sender, e);
    }
    else if (fThird.Enabled == true)
    {
        //
    }
}

When I click on Button Next it goes to fSecond form but when I click again on Button Next it doing nothing...
I think if else condition not working for it.
If there is another way to do the same job please tell how will code looks like

Upvotes: 0

Views: 39

Answers (1)

MaxOvrdrv
MaxOvrdrv

Reputation: 1916

if (fFirst.Visible == true)
        {
            fFirst.Hide();
            lectureSecondToolStripMenuItem_Click(sender, e);
        }
        else if (fSecond.Visible == true)
        {
            fSecond.Hide();
            lectureThirdToolStripMenuItem_Click(sender, e);
        }
        else if (fThird.Visible == true)
        {
           //
        }

Upvotes: 1

Related Questions