April 27, 2012

C# CheckBox


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 WindowsFormsApplication11
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
         
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int d = 0;
            int y = 0;
            if ((checkBox1.Checked) && (checkBox3.Checked) && (checkBox2.Checked == false) &&                     (checkBox4.Checked == false))
            {
                d = d + 1;
            }

            else
            {
                y = y + 1;
            }

            if ((checkBox5.Checked == false) && (checkBox6.Checked == false) &&
                                                                    (checkBox7.Checked == false) && (checkBox8.Checked))
            {
                d = d + 1;
            }

            else
            {
                y = y + 1;
            }

            checkBox1.BackColor = Color.PaleGreen;
            checkBox3.BackColor = Color.PaleGreen;
            checkBox8.BackColor = Color.PaleGreen;

            label5.Text = d.ToString();
            label6.Text = y.ToString() ;


        }

    }
}

No comments:

Post a Comment