C# - How To Check And Uncheck All CheckBoxes In C#
_________________________________________________
In This C# Tutorial We Will See How To Check And Uncheck All CheckBoxes In CSharp Programming Language .
In This C# Tutorial We Will See How To Check And Uncheck All CheckBoxes In CSharp Programming Language .
Project Source Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class CheckBoxes_Check_UnCheck : Form
{
public CheckBoxes_Check_UnCheck()
{
InitializeComponent();
}
private void BTN_F_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;
BTN_F.Text = "Uncheck";
}
else
{
cb.Checked = false;
BTN_F.Text = "Check";
}
}
}
}
private void BTN_G_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;
BTN_G.Text = "Uncheck";
}
else
{
cb.Checked = false;
BTN_G.Text = "Check";
}
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class CheckBoxes_Check_UnCheck : Form
{
public CheckBoxes_Check_UnCheck()
{
InitializeComponent();
}
private void BTN_F_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;
BTN_F.Text = "Uncheck";
}
else
{
cb.Checked = false;
BTN_F.Text = "Check";
}
}
}
}
private void BTN_G_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;
BTN_G.Text = "Uncheck";
}
else
{
cb.Checked = false;
BTN_G.Text = "Check";
}
}
}
}
}
}
=> OutPut :
CheckBoxes_Check_UnCheck |