Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.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#,现在我想以最好的方式启用或禁用该列文本框,可能不使用数组或循环。我该怎么做 // create a column of textboxes dynamically private void CreateControl(int ControlId) { CheckBox control1 = new CheckBox(); control1.Click += new EventHandler(chk_CheckedChanged);

现在我想以最好的方式启用或禁用该列文本框,可能不使用数组或循环。我该怎么做

// create a column of textboxes dynamically
   private void CreateControl(int ControlId)
{

            CheckBox control1 = new CheckBox();

            control1.Click += new EventHandler(chk_CheckedChanged);

            Point point = GetPoint(ControlId);
        control1.Location = point;
        this.Controls.Add(control1);


}

// a check box to enable or disable that column of textboxes
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
    Column column = new Column();
  CheckBox  chk = (CheckBox) sender;
  if (chk.Checked)
  {


      column.EnterName.Enabled = true;
// I want to enable or disable the entire column of textboxes

  }
}


Public Class Column 
{
  public TextBox EnterName {get;set;}
}
  • 添加一个GroupBox或一个面板(如果你没有创造一个什么都没有的幻觉,没有边框)来容纳文本框列
  • 根据需要切换Groupbox的Enabled属性

我想这样行。

y您不想使用数组或循环吗?