Sunday, 9 September 2012

10.Form Events


Form Events

using System.Windows.Forms;
namespace samp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            String str = "", str2 = "";
            if (textBox1.Text != "")
            {
                str += "name is" + textBox1.Text + "\n";
            }
            else
            {                str2 += "enter name\n";
            }
            if (textBox2.Text != "")
            {
                str += "age is" + textBox2.Text + "\n";
            }
            else
            {                str2 += "enter age\n";
            }
            if (textBox3.Text != "")
            {
                str += "Phno is" + textBox3.Text + "\n";
            }
            else
            {                str2 += "enter phno\n";
            }
            if (radioButton1.Checked)
                str += "gender is:" + radioButton1.Text + "\n";
            else if (radioButton2.Checked)
                str += "gender is:" + radioButton1.Text + "\n";
            else
                str2 += "enter gender\n";
           if (checkBox1.Checked)
                str += "Hobbies is:" + checkBox1.Text + "\n";
            else if (checkBox2.Checked)
                str += "Hobbies is:" + checkBox2.Text + "\n";
            else if (checkBox3.Checked)
                str += "Hobbies is:" + checkBox3.Text + "\n";
            else
                str2 += "enter Hobbies\n";
            if (str2 != "")
            {                MessageBox.Show(str2);
            }
            else
            {                MessageBox.Show(str);
            }
        }    }      }

No comments:

Post a Comment