How To Create Checkbox Control In C# .NET

Hello Readers and Friends! I am happy to share some of my codes and applications. Today, I am discussing about some of the basic things in C# programming that is Checkbox Control in Windows application.

Step 1: Open Visual Studio (any version you have installed). I have VS2012,

open

Step 2: Select Windows form application and enter the name of application, then click OK.

window form application

Step 3: Design your windows application, like drag and drop the checkbox, buttons and labels, as per your requirement.

application

Step 4: The source code of my program is given below.

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.ComponentModel;  
  4. using System.Data;  
  5. using System.Drawing;  
  6. using System.Linq;  
  7. using System.Text;  
  8. using System.Threading.Tasks;  
  9. using System.Windows.Forms;  
  10.   
  11. namespace Checkbox_Apps  
  12. {  
  13.     public partial class Form1 : Form  
  14.     {  
  15.         public Form1()  
  16.         {  
  17.             InitializeComponent();  
  18.         }  
  19.   
  20.         private void checkBox1_CheckedChanged(object sender, EventArgs e)  
  21.         {  
  22.             checkBox1.ThreeState = true;  
  23.         }  
  24.   
  25.         private void label1_Click(object sender, EventArgs e)  
  26.         {  
  27.   
  28.   
  29.   
  30.         }  
  31.   
  32.         private void checkBox2_CheckedChanged(object sender, EventArgs e)  
  33.         {  
  34.             checkBox2.ThreeState = true;  
  35.   
  36.         }  
  37.   
  38.         private void checkBox3_CheckedChanged(object sender, EventArgs e)  
  39.         {  
  40.             checkBox3.ThreeState = true;  
  41.   
  42.         }  
  43.   
  44.         private void checkBox4_CheckedChanged(object sender, EventArgs e)  
  45.         {  
  46.             checkBox4.ThreeState = true;  
  47.   
  48.         }  
  49.   
  50.         private void button1_Click(object sender, EventArgs e)  
  51.         {  
  52.             //string messagebox = "";  
  53.             if (checkBox1.Checked == true)  
  54.             {  
  55.                 MessageBox.Show("Welcome to Visual Studio DownLoad Page Click Visit");  
  56.                 System.Diagnostics.Process.Start("www.visualstudio.com");  
  57.             }  
  58.             if (checkBox2.Checked == true)  
  59.             {  
  60.                 MessageBox.Show("Welcome to Dev C DownLoad Page Click Visit");  
  61.                 System.Diagnostics.Process.Start("www.krishnasinghprogramming.blogspot.com");  
  62.             }  
  63.             if (checkBox3.Checked == true)  
  64.             {  
  65.                 MessageBox.Show("Welcome to IT PROGRAMMING WORLD Page Click Visit");  
  66.                 System.Diagnostics.Process.Start("www.krishnasinghprogramming.blogspot.com");  
  67.             }  
  68.             if (checkBox4.Checked == true)  
  69.             {  
  70.                 MessageBox.Show("Welcome to CSHARPCORNER Page Click Visit");  
  71.                 System.Diagnostics.Process.Start("www.csharpcorner.com");  
  72.             }  
  73.         }  
  74.   
  75.         private void button2_Click(object sender, EventArgs e)  
  76.         {  
  77.             checkBox1.Checked = false;  
  78.             checkBox2.Checked = false;  
  79.             checkBox3.Checked = false;  
  80.             checkBox4.Checked = false;  
  81.   
  82.             {  
  83.             }  
  84.   
  85.         }  
  86.   
  87.         private void label2_Click(object sender, EventArgs e)  
  88.         {  
  89.             label2.Text = DateTime.Now.ToShortTimeString();  
  90.         }  
  91.     }  
  92. }  
Step 5: The output will be as following:

Output

Thank you for reading. I hope this article proves to be helpful to you. 

 

X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now