Question

In: Computer Science

Create a Windows application in C# that can be used to change the form color. Your...

Create a Windows application in C# 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.

Solutions

Expert Solution

Greetings!!!!!!!!!!!!!!!!!

Please find detail of Window application in c#. It includes following deliverables as part of question.

1) Screen shot of the solution in design mode.

2) ChangeFormColor.cs code in C#

3) ChangeFormColor.Designer.cs code in c#

4) Screen shots of sample run

i) Initially Blue Color of form as back color

ii) Red Color button clicked to change back color to red with message box of current color.

iii) Green Color button clicked to change back color to green with message box of current color.

iv) Reset Color button clicked to change back color to default (blue) with message box of current color.

1) Screen shot of the solution in design mode.

2) ChangeFormColor.cs code in C#

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

                private void ChangeFormColor_Load(object sender, EventArgs e)
                {

                }

                private void btnRedColor_Click(object sender, EventArgs e)
                {
                        this.BackColor = Color.Red;
                        MessageBox.Show("Back Color of form is changed to red.");
                        
                }

                private void btnGreenColor_Click(object sender, EventArgs e)
                {
                        this.BackColor = Color.Green;
                        MessageBox.Show("Back Color of form is changed to green.");
                }

                private void btnResetColor_Click(object sender, EventArgs e)
                {
                        this.BackColor = Color.Blue;
                        MessageBox.Show("Back Color of form is reset to blue.");
                }
        }
}

3) ChangeFormColor.Designer.cs code in c#

namespace ChangeColorOfWindowForm
{
        partial class ChangeFormColor
        {
                /// <summary>
                /// Required designer variable.
                /// </summary>
                private System.ComponentModel.IContainer components = null;

                /// <summary>
                /// Clean up any resources being used.
                /// </summary>
                /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
                protected override void Dispose(bool disposing)
                {
                        if (disposing && (components != null))
                        {
                                components.Dispose();
                        }
                        base.Dispose(disposing);
                }

                #region Windows Form Designer generated code

                /// <summary>
                /// Required method for Designer support - do not modify
                /// the contents of this method with the code editor.
                /// </summary>
                private void InitializeComponent()
                {
                        this.btnRedColor = new System.Windows.Forms.Button();
                        this.btnGreenColor = new System.Windows.Forms.Button();
                        this.btnResetColor = new System.Windows.Forms.Button();
                        this.SuspendLayout();
                        // 
                        // btnRedColor
                        // 
                        this.btnRedColor.Location = new System.Drawing.Point(259, 193);
                        this.btnRedColor.Name = "btnRedColor";
                        this.btnRedColor.Size = new System.Drawing.Size(75, 23);
                        this.btnRedColor.TabIndex = 0;
                        this.btnRedColor.Text = "Red Color";
                        this.btnRedColor.UseVisualStyleBackColor = true;
                        this.btnRedColor.Click += new System.EventHandler(this.btnRedColor_Click);
                        // 
                        // btnGreenColor
                        // 
                        this.btnGreenColor.Location = new System.Drawing.Point(386, 193);
                        this.btnGreenColor.Name = "btnGreenColor";
                        this.btnGreenColor.Size = new System.Drawing.Size(75, 23);
                        this.btnGreenColor.TabIndex = 1;
                        this.btnGreenColor.Text = "Green Color";
                        this.btnGreenColor.UseVisualStyleBackColor = true;
                        this.btnGreenColor.Click += new System.EventHandler(this.btnGreenColor_Click);
                        // 
                        // btnResetColor
                        // 
                        this.btnResetColor.Location = new System.Drawing.Point(499, 193);
                        this.btnResetColor.Name = "btnResetColor";
                        this.btnResetColor.Size = new System.Drawing.Size(75, 23);
                        this.btnResetColor.TabIndex = 2;
                        this.btnResetColor.Text = "Reset Color";
                        this.btnResetColor.UseVisualStyleBackColor = true;
                        this.btnResetColor.Click += new System.EventHandler(this.btnResetColor_Click);
                        // 
                        // ChangeFormColor
                        // 
                        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                        this.BackColor = System.Drawing.Color.Blue;
                        this.ClientSize = new System.Drawing.Size(800, 450);
                        this.Controls.Add(this.btnResetColor);
                        this.Controls.Add(this.btnGreenColor);
                        this.Controls.Add(this.btnRedColor);
                        this.Name = "ChangeFormColor";
                        this.Text = "Change Back Color of Form";
                        this.Load += new System.EventHandler(this.ChangeFormColor_Load);
                        this.ResumeLayout(false);

                }

                #endregion

                private System.Windows.Forms.Button btnRedColor;
                private System.Windows.Forms.Button btnGreenColor;
                private System.Windows.Forms.Button btnResetColor;
        }
}

4) Screen shots of sample run

i) Initially Blue Color of form as back color

ii) Red Color button clicked to change back color to red with message box of current color.

iii) Green Color button clicked to change back color to green with message box of current color.

iv) Reset Color button clicked to change back color to default (blue) with message box of current color.

Thank You


Related Solutions

Create a windows form application in C# that looks and functions like a basic calculator. It...
Create a windows form application in C# that looks and functions like a basic calculator. It must do the following: Add, subtract, multiply, and divide. Account for division by zero. Show at least two decimal places. Retain the last number on the window so that, when the user opens the calculator the next time, the number that was in the window at the last close appears. Have a memory, so that users can store values and recall them. Operate with...
C# Programming; Create a Windows Form Application that displays a scrollable list of 10 random integers...
C# Programming; Create a Windows Form Application that displays a scrollable list of 10 random integers in the range of 1 to 100. The form should also have (1) an Add button (and input textbox) for the user to add a new number to the list, (2) a Delete button to delete the current selected integer, (3) a Sort button to sort the list, (4) a Reverse button to display the list in reverse order, and (5) Display Multiple (and...
C# windows application form. Create a base class to store characteristics about a loan. Include customer...
C# windows application form. Create a base class to store characteristics about a loan. Include customer details in the Loan base class such as name, loan number, and amount of loan. Define subclasses of auto loan and home loan. Include unique characteristics in the derived classes. For example you might include details about the specific auto in the auto loan class and details about the home in the home loan class. Create a presentation class to test your design by...
C# Programming Discuss how to build a Multi-Form Windows application in C#. That is an App...
C# Programming Discuss how to build a Multi-Form Windows application in C#. That is an App that has more than one form, like say maybe 5 forms. How do you connect these forms and pass data objects between these forms?
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates...
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates and displays the total travel expenses of a business person on a trip. Here is the information that the user must provide: • Number of days on the trip • Amount of airfare, if any • Amount of car rental fees, if any • Number of miles driven, if a private vehicle was used • Amount of parking fees, if any • Amount of...
A, B:   Design and Implement a C# windows form application to ask the user for 10...
A, B:   Design and Implement a C# windows form application to ask the user for 10 integer numbers, sort them in ascending order and display the sorted list. Use bubble sort technique to sort the array elements and do not use any built-in sort method to sort the array elements.                                                        [02] C:    Test and evaluate your program by inputting variety of values.
A, B:    Design and Implement a C# windows form application to encrypt and decrypt text....
A, B:    Design and Implement a C# windows form application to encrypt and decrypt text. The application use to receive a string and display another encrypted string. The application also decrypt the encrypted string. The approach for encryption/decryption is simple one i.e. to encrypt we will add 1 to each character, so that "hello" would become "ifmmp", and to decrypt we would subtract 1 from each character.    C:   Test and evaluate application by applying different strings.      ...
Must be in Visual C# using windows forms : Create an application that opens a specified...
Must be in Visual C# using windows forms : Create an application that opens a specified text file and then displays a list of all the unique words found in the file. Hint: Use a LINQ method to remove all duplicate words.
In C# Create a windows application which accepts the month number and displays the month name...
In C# Create a windows application which accepts the month number and displays the month name in a label.   Use a nested if... else statement to determine the month name. For months not in the range 1-12 display the message "Not a valid month"
How to make an application for windows using c# ?
How to make an application for windows using c# ?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT