C#.NET Program 25

Output:
























Code:

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

       

        private void button1_Click(object sender, EventArgs e)
        {
            ColorDialog SelectColor = new ColorDialog();
            if (SelectColor.ShowDialog() == DialogResult.OK)
            {
                textBox1.BackColor = SelectColor.Color;
                textBox1.Clear();

                if (SelectColor.ShowDialog() == DialogResult.OK)
                {
                    textBox1.ForeColor = SelectColor.Color;
                }
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (textBox1.Text.Length > 5)
            {
                textBox1.BackColor = Color.Blue;
                textBox1.ForeColor = Color.Red;
            }
            if (textBox1.Text.Length < -0)
            {
                textBox1.BackColor = Color.White;
                MessageBox.Show("Your Text Box Does't Have Any Text");
            }
            if (textBox1.Text == "A" || textBox1.Text == "E" || textBox1.Text == "I" || textBox1.Text == "O" || textBox1.Text == "U")
            {
                MessageBox.Show("Your First Character Is Vowels");
                textBox1.BackColor = Color.Turquoise;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Clear();
            textBox1.BackColor = Color.White;
            textBox1.ForeColor = Color.Black;
        }
    }
}



No comments:

Post a Comment