Create a Windows application that can be used to change the form color. Your form background color should initially be blue. Provide at least two buttons with two different color choices and a Reset option. Change the font style and size on buttons. Align the buttons so that they are in the center of the form. The color choice buttons should be the same size. Add event handlers for the buttons so that when the user click the button, the form changes the color, and the message box is displayed alerting the user to what color the form is. Be sure to name any controls used in the program statements prior to registering your event. Change the default title bar text. Must be in C#.
COde:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Form_Color
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.BackColor = Color.Blue;
}
private void btnRed_Click(object sender, EventArgs e)
{
this.BackColor = Color.Red;
MessageBox.Show("Red");
}
private void btnYelow_Click(object sender, EventArgs e)
{
this.BackColor = Color.Yellow;
MessageBox.Show("Yellow");
}
private void btnReset_Click(object sender, EventArgs e)
{
this.BackColor = Color.Blue;
}
}
}
Output:
Get Answers For Free
Most questions answered within 1 hours.