【问题标题】:Multiple Buttons in One Handler Not Working Properly一个处理程序中的多个按钮无法正常工作
【发布时间】:2014-05-01 16:35:19
【问题描述】:

我正在处理我有多个按钮的项目。
我只想使用一个处理程序按钮进行多次点击。
我有以下此类按钮 Next 的代码,但它无法正常工作

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)
    {
        //
    }
}

当我单击 Button Next 时,它进入 fSecond 表单,但是当我再次单击 Button Next 时,它什么也不做...
我认为如果其他条件不适合它。
如果有其他方法可以做同样的工作,请告诉代码是什么样子的

【问题讨论】:

  • 我认为您正在寻找 .Visible,而不是 .Enabled,因为您似乎在使用 .Hide()...

标签: c# winforms


【解决方案1】:
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)
        {
           //
        }

【讨论】:

    猜你喜欢
    • 2014-10-23
    • 2016-09-18
    • 1970-01-01
    • 1970-01-01
    • 2017-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-04
    相关资源
    最近更新 更多