// 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 DefaultNamespace { public class MainForm : Form { private CheckBox a262; private CheckBox a263; private CheckBox a261; private CheckBox a264; private Button button1; public MainForm() { InitializeComponent(); } [STAThread] public static void Main(string[] args) { Application.Run(new MainForm()); } private void InitializeComponent() { button1 = new Button(); a261 = new CheckBox(); a263 = new CheckBox(); a262 = new CheckBox(); a264 = new CheckBox(); SuspendLayout(); button1.Location = new Point(50, 450); button1.Size = new Size(300, 50); button1.Name = "button1"; button1.Text = "Set"; button1.Click += new EventHandler(Button1Click); a261.Location = new Point(50, 50); a261.Name = "a261"; a261.Text = "#1"; a262.Location = new Point(50, 150); a262.Name = "a262"; a262.Text = "#2"; a263.Location = new Point(50, 250); a263.Name = "a263"; a263.Text = "#3"; a264.Location = new Point(50, 350); a264.Name = "a264"; a264.Text = "#4"; ClientSize = new Size(400, 550); Controls.Add(button1); Controls.Add(a264); Controls.Add(a263); Controls.Add(a262); Controls.Add(a261); Name = "MainForm"; Text = "Main Form"; ResumeLayout(false); } void Button1Click(object sender, System.EventArgs e) { foreach(Control c in Controls) { if(c is CheckBox) { if(c.Name.IndexOf("a26") == 0) { ((CheckBox)c).Checked = true; } } } } } }