Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 创建动态按钮和访问某些特定按钮_C# - Fatal编程技术网

C# 创建动态按钮和访问某些特定按钮

C# 创建动态按钮和访问某些特定按钮,c#,C#,我在做一个项目,我怀疑是否将组合框值与动态创建的按钮链接?在这些按钮中,如果创建了“n”个按钮,我怎么能只访问一些特定的按钮。。我应该怎么做呢?创建一个类似 public void enableAsRequired() { if (comboBox.Text.equals("something")) { button1.Enabled = true; button2.Enabled = true; button3.Enabled =

我在做一个项目,我怀疑是否将组合框值与动态创建的按钮链接?在这些按钮中,如果创建了“n”个按钮,我怎么能只访问一些特定的按钮。。我应该怎么做呢?

创建一个类似

public void enableAsRequired()
{
    if (comboBox.Text.equals("something"))
    {
        button1.Enabled = true;
        button2.Enabled = true;
        button3.Enabled = false;
        ...
    }
    else if (...) { ... }
    else {...}
}
从事件和文本框中调用它