C# - How To check And UnCheck All CheckBoxes In The GroupBox Or In The Form
Project Source Code:
///////////OUTPUT: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 WindowsFormsApplication1 { public partial class Project : Form { public Project() { InitializeComponent(); }
//button to check all checkbox in form private void checkF_Click(object sender, EventArgs e) { foreach (Control c in Controls) { if (c is CheckBox) { CheckBox cb = (CheckBox)c; if (cb.Checked == false) { cb.Checked = true; checkF.Text = "UnCheck"; } else { cb.Checked = false; checkF.Text = "Check"; } } } }
//button to check all checkbox in groupBox private void checkG_Click(object sender, EventArgs e) { foreach (Control c in groupBox1.Controls) { if (c is CheckBox) { CheckBox cb = (CheckBox)c; if (cb.Checked == false) { cb.Checked = true; checkG.Text = "UnCheck"; } else { cb.Checked = false; checkG.Text = "Check"; } } } } } }
///////////////////// END
Download Projects Source Code
1 comments:
commentsfd
Reply