// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Drawing; using System.Windows.Forms; namespace MyFormProject { class MainForm : Form { private TextBox txtbx; private ComboBox cmbbx; private CheckBox chkbx; private Control[] all; private Button btn; public MainForm() { txtbx = new TextBox(); txtbx.Location = new Point(100,100); cmbbx = new ComboBox(); cmbbx.Location = new Point(100,200); cmbbx.Items.Add("aaa"); cmbbx.Items.Add("bbb"); cmbbx.Items.Add("ccc"); chkbx = new CheckBox(); chkbx.Location = new Point(100,300); all = new Control[3] { txtbx, cmbbx, chkbx }; btn = new Button(); btn.Text = "Toggle visibility"; btn.Location = new Point(225, 300); btn.Size = new Size(150, 25); btn.Click += new EventHandler(ClickHandler); ClientSize = new Size(400, 400); Controls.Add(txtbx); Controls.Add(cmbbx); Controls.Add(chkbx); Controls.Add(btn); Text = "Visibility test"; } private void ClickHandler(object o, EventArgs e) { for(int i = 0; i < all.Length; i++) { all[i].Visible = !all[i].Visible; } } [STAThread] public static void Main(string[] args) { Application.Run(new MainForm()); } } }