Click here to Skip to main content
15,896,207 members
Articles / Desktop Programming / Windows Forms

Disabling and Re-enabling Control Collections

Rate me:
Please Sign up or sign in to vote.
4.48/5 (6 votes)
3 Jan 2011CPOL4 min read 40.8K   352   12  
Disabling a control collection, and returning all sub controls to their respective Enabled state when re-enabling the collection
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Dummy
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void checkBox7_CheckedChanged(object sender, EventArgs e)
        {
            checkBox6.Enabled = checkBox7.Checked;
        }

        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            textBox1.Enabled = checkBox2.Checked;
        }

        private void checkBox3_CheckedChanged(object sender, EventArgs e)
        {
            button1.Enabled = checkBox3.Checked;
        }

        private void checkBox4_CheckedChanged(object sender, EventArgs e)
        {
            checkBox1.Enabled = checkBox4.Checked;
        }

        private void checkBox5_CheckedChanged(object sender, EventArgs e)
        {
            groupBox1.Enabled = checkBox5.Checked;
        }

        private void checkBox9_CheckedChanged(object sender, EventArgs e)
        {
            textBox2.Enabled = checkBox9.Checked;
        }

        private void checkBox8_CheckedChanged(object sender, EventArgs e)
        {
            button2.Enabled = checkBox8.Checked;
        }

        private void checkBox10_CheckedChanged(object sender, EventArgs e)
        {
            groupBox2.Enabled = checkBox10.Checked;
        }

        private void checkBox13_CheckedChanged(object sender, EventArgs e)
        {
            textBox3.Enabled = checkBox13.Checked;
        }

        private void checkBox12_CheckedChanged(object sender, EventArgs e)
        {
            button3.Enabled = checkBox12.Checked;
        }

        private void checkBox11_CheckedChanged(object sender, EventArgs e)
        {
            checkBox14.Enabled = checkBox11.Checked;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Form2 form2 = new Form2(this);
            form2.Show();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader
Canada Canada
A developer that's been tinkering with computers since he first laid eyes on his buddy's Atari in the mid 80's and messed around with GWBasic and Logo. He now divides his time among his wife, kids, and evil mistress (a term lovingly [ahem...] given to his computer by the wife ...).

For more info, please see my LinkedIn profile: http://www.linkedin.com/pub/david-catriel/44/b01/382

Comments and Discussions