Write a Windows form application C that can 1 Read a numberD
Write a Windows form application, C# that can
1. Read a number/Date and Time from a text box
2. Write to a rich text box and add names to a list box (select name , display to rich text )
3.Set up a countdown timer (by 1 second)
4. Button to clear rich text box
Please and thank you
Solution
using System;
using System.Drawing;
using System.Windows.Forms;
namespace formApplication
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form_Load(object sender, EventArgs e)
{
textBox1.Width = 250;
textBox1.Height = 50;
textBox1.Multiline = true;
textBox1.BackColor = Color.Blue;
textBox1.ForeColor = Color.White;
textBox1.BorderStyle = BorderStyle.Fixed3D;
richTextBox1.Font = new Font(\"Consolas\", 18f, FontStyle.Bold);
richTextBox1.BackColor = Color.AliceBlue;
string[] words =
{
\"Dot\",
\"Net\",
\"Perls\",
\"is\",
\"a\",
\"nice\",
\"website.\"
};
for (int i = 0; i < words.Length; i++)
{
string word = words[i];
{
listBox1.Items.Add(word);
}
}
listBox1.SelectionMode = SelectionMode.MultiSimple;
}
private void timer_Tick(object sender, EventArgs e)
{
if (timeLeft > 0)
{
// display time left
timeLeft = timeLeft - 1;
timeLabel.Text = timeLeft + \" seconds\";
}
else
{
// if timer completed
timer1.Stop();
timeLabel.Text = \"Time up!\";
startButton.Enabled = true;
}
}
private void button_Click(object sender, EventArgs e)
{
string var;
var = textBox1.Text;
MessageBox.Show(var);
}
}
}

