【问题标题】:c# button 2 can only be click after button 1 clickedc# 按钮 2 只能在单击按钮 1 后单击
【发布时间】:2017-05-04 15:17:53
【问题描述】:

我真的是 C# 和 Visual Studio 的新手

我的情况是我有两个按钮,button1_click(进行一些处理)和button2_click(进行下一个处理)

我想问的是,有没有可能设置button2_click只能在用户首先点击button1_click后才能点击..

感谢您的回复!

【问题讨论】:

    标签: c# .net


    【解决方案1】:

    是的,这是可能的,要做到这一点,您必须首先禁用Button2,然后在Button1 的Click 事件中启用它;类似于以下内容:

    private void Button1_Click(object sender, EventArgs e)
    {
       if("some condition if needed")
       {
           Button2.Enabled = true;
       }
    }
    

    确保最初禁用Button2,否则在页面/表单加载中包含此Button2.Enabled = false;

    【讨论】:

      【解决方案2】:

      将 button2 启用属性设置为 false。 并在 button1_click 事件处理程序中将 button2 enabled 属性设置为 true。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-06-16
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多