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. namespace Checkbox_Apps
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. }
  18. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  19. {
  20. checkBox1.ThreeState = true;
  21. }
  22. private void label1_Click(object sender, EventArgs e)
  23. {
  24. }
  25. private void checkBox2_CheckedChanged(object sender, EventArgs e)
  26. {
  27. checkBox2.ThreeState = true;
  28. }
  29. private void checkBox3_CheckedChanged(object sender, EventArgs e)
  30. {
  31. checkBox3.ThreeState = true;
  32. }
  33. private void checkBox4_CheckedChanged(object sender, EventArgs e)
  34. {
  35. checkBox4.ThreeState = true;
  36. }
  37. private void button1_Click(object sender, EventArgs e)
  38. {
  39. //string messagebox = "";
  40. if (checkBox1.Checked == true)
  41. {
  42. MessageBox.Show("Welcome to Visual Studio DownLoad Page Click Visit");
  43. System.Diagnostics.Process.Start("www.visualstudio.com");
  44. }
  45. if (checkBox2.Checked == true)
  46. {
  47. MessageBox.Show("Welcome to Dev C DownLoad Page Click Visit");
  48. System.Diagnostics.Process.Start("www.krishnasinghprogramming.blogspot.com");
  49. }
  50. if (checkBox3.Checked == true)
  51. {
  52. MessageBox.Show("Welcome to IT PROGRAMMING WORLD Page Click Visit");
  53. System.Diagnostics.Process.Start("www.krishnasinghprogramming.blogspot.com");
  54. }
  55. if (checkBox4.Checked == true)
  56. {
  57. MessageBox.Show("Welcome to CSHARPCORNER Page Click Visit");
  58. System.Diagnostics.Process.Start("www.csharpcorner.com");
  59. }
  60. }
  61. private void button2_Click(object sender, EventArgs e)
  62. {
  63. checkBox1.Checked = false;
  64. checkBox2.Checked = false;
  65. checkBox3.Checked = false;
  66. checkBox4.Checked = false;
  67. {
  68. }
  69. }
  70. private void label2_Click(object sender, EventArgs e)
  71. {
  72. label2.Text = DateTime.Now.ToShortTimeString();
  73. }
  74. }
  75. }
Step 5: The output will be as following:

Output

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