Getsuyodev, Programming is mainly used when constructing an application. Programming requires knowledge of application domains, algorithms, and programming language expertise. Programming can be developed in different logic based on developer knowledge.

C# CheckBox Control



CheckBoxes allow the user to make multiple selections from several options. CheckBox to give the user an opportunity, such as true/false or yes/no. You can click a checkbox to select it and click it again to deselect it.

The CheckBox control can display an image or text or both. Usually, CheckBox comes with a caption, which you can set in the Text property.

checkBox1.Text = "getsuyodev.com";

You can use the CheckBox control ThreeState property to direct the control to return the Checked, Unchecked, and Indeterminate values. You need to set the checkboxes ThreeState property to True to indicate that you want it to support three states.

checkBox1.ThreeState = true;

The radio button and the checkbox are used for different functions. Use a radio button when you want the user to choose only one option. When you want the user to choose all appropriate options, use a checkbox. The following C# program shows how to find a checkbox is selected or not.

using System;
using System.Drawing;
using System.Windows.Forms;

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

        private void button1_Click(object sender, EventArgs e)
        {
            string msg = "";

            if (checkBox1.Checked == true)
            {
                msg = "getsuyodev.com/open-source/";
            }

            if (checkBox2.Checked == true)
            {
                msg = msg + "   getsuyodev.com/services/";
            }

            if (checkBox3.Checked == true)
            {
                msg = msg + "   getsuyodev.com/bridge/";
            }


            if (msg.Length > 0)
            {
                MessageBox.Show (msg + " selected ");
            }
            else
            {
                MessageBox.Show ("No checkbox selected");
            }

            checkBox1.ThreeState = true;
        }
    }
}

Comments are closed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More