简体   繁体   English

如何启用或禁用文本框列?

[英]How do I enable or disable a column of textboxes?

Now I want to enable or disable that column of textboxes in the best possible way, perhaps not using array or loops. 现在,我想以最佳方式启用或禁用该列文本框,也许不使用数组或循环。 How do I do it? 我该怎么做?

// 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;}
}
  • Add a GroupBox or a Panel (if you dont create the illusion of there's nothing there.. no border) to house the column of textboxes 添加一个GroupBox或一个Panel(如果您不创建没有任何效果的错觉..没有边框)以容纳文本框的列
  • Toggle the Enabled property of the Groupbox as required. 根据需要切换Groupbox的Enabled属性。

I think that'd work. 我认为那行得通。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM