新人求教关于C#中对动态生成的按钮怎么实现每一次只能对一个按钮操作的有关问题

新人求教关于C#中对动态生成的按钮如何实现每一次只能对一个按钮操作的问题
我最近有一个项目,里面碰到一个关于动态按钮的问题

首先我实现了按照数据库里的数据(比如某些物品的ID)动态的生成相对应的按钮,并且显示在panel上面

然后,在我点击完某个按钮之后,将点击的那个按钮变灰(这个已经实现),在将其他的按钮设置为不可按(注:不是变灰。是点击其他的按钮时,会提示这些按钮不能按,请进行和之前变灰的按钮的相关的下一步操作)

我想要求解的就是怎么样在点击一个按钮后让其他的按钮都设置为不可按状态

不知道我说的各位大大是不是看明白了,我觉得我的描述能力了可能不咋滴。。。O(∩_∩)O~

求各位大大帮帮忙哦


------解决方案--------------------
遍历panel的Controls,除了你点击的那个以外,其他的都做上标记,比如tag=-1,当点击时,判断如果tag=-1,那么就提示
------解决方案--------------------
在点击一个按钮的时候遍历页面或者窗体上的所有按钮,然后判断按钮的ID是否和你点击的一样,其他按钮不可用
------解决方案--------------------
探讨
遍历panel的Controls,除了你点击的那个以外,其他的都做上标记,比如tag=-1,当点击时,判断如果tag=-1,那么就提示

------解决方案--------------------
探讨
我想要求解的就是怎么样在点击一个按钮后让其他的按钮都设置为不可按状态


------解决方案--------------------
C# code

using System;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Form["btn2"] != null)
        {
            Response.Write("S");
        }

        Button btn1 = new Button();
        btn1.Text = "button1";
        this.form1.Controls.Add(btn1);
        btn1.Click += (o, ev) =>
            {
                Button btn2 = new Button();
                btn2.Text = "button2";
                btn2.ID="btn2";
                this.form1.Controls.Add(btn2);
            };
    }
}

------解决方案--------------------
C# code

 

private void button1_Click(object sender, EventArgs e)
        {
            Button newbtn = new Button();
            newbtn.Name = "new";
            newbtn.Text = "new";
            newbtn.Size = new Size(100, 50);
            newbtn.Location = new Point(newbtn.Location.X+200,newbtn.Location.Y+100);
            newbtn.Visible = true;
            this.Controls.Add(newbtn);
            newbtn.Click += new EventHandler(newbtn_click);
            
        }
        private void newbtn_click(object sender, EventArgs e)
        {
            MessageBox.Show("success");
        }

------解决方案--------------------
取消button注册的事件
C# code

        private void button1_Click(object sender, EventArgs e)
        {
            button2.Click -= new EventHandler(button2_Click); //取消button2注册的事件
        }

        private void button2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Hello");
        }
//先点击button2里会弹出"Hello"对话框的;若先点button1,再点button2就不会弹出"Hello"对话框了