Write a C# Windows Form program that asks the user to enter a name (in a TextBox) and displays the following message (in a Label): Hello, yourName! https://youtu.be/6nNiMeWK37w can be helpful... (unfortunately the sound did not record) You will use Visual studio to complete this task. The final deliverable to be uploaded to the assignment dropbox is the entire visual studio solution folder that has been compressed or zipped.
Dear Student ,
As per the requirement submitted above , kindly find the below solution.
Here a new Windows Forms Application in C# is created using Visual Studio 2017 with name "Demo_NameApp".This application contains a form with name "Form1.cs".Below are the files associated with form1.
1.Form1.cs[Design]
2.Form1.Designer.cs
namespace Demo_NameApp
{
partial class Form1
{
/// <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.lblName = new System.Windows.Forms.Label();
this.txtName = new System.Windows.Forms.TextBox();
this.btnDisplayName = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.lblMessage = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// lblName
//
this.lblName.AutoSize = true;
this.lblName.Location = new System.Drawing.Point(28, 48);
this.lblName.Name = "lblName";
this.lblName.Size = new System.Drawing.Size(106, 20);
this.lblName.TabIndex = 0;
this.lblName.Text = "Enter Name : ";
//
// txtName
//
this.txtName.Location = new System.Drawing.Point(155, 42);
this.txtName.Name = "txtName";
this.txtName.Size = new System.Drawing.Size(182, 26);
this.txtName.TabIndex = 1;
//
// btnDisplayName
//
this.btnDisplayName.Location = new System.Drawing.Point(70,
91);
this.btnDisplayName.Name = "btnDisplayName";
this.btnDisplayName.Size = new System.Drawing.Size(120, 31);
this.btnDisplayName.TabIndex = 2;
this.btnDisplayName.Text = "&Display Name";
this.btnDisplayName.UseVisualStyleBackColor = true;
this.btnDisplayName.Click += new
System.EventHandler(this.btnDisplayName_Click);
//
// btnExit
//
this.btnExit.Location = new System.Drawing.Point(206, 91);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(88, 31);
this.btnExit.TabIndex = 3;
this.btnExit.Text = "E&xit";
this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += new
System.EventHandler(this.btnExit_Click);
//
// lblMessage
//
this.lblMessage.AutoSize = true;
this.lblMessage.Location = new System.Drawing.Point(122,
157);
this.lblMessage.Name = "lblMessage";
this.lblMessage.Size = new System.Drawing.Size(0, 20);
this.lblMessage.TabIndex = 4;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(369, 224);
this.Controls.Add(this.lblMessage);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnDisplayName);
this.Controls.Add(this.txtName);
this.Controls.Add(this.lblName);
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F,
System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.Name = "Form1";
this.Text = "Display Name";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label lblName;
private System.Windows.Forms.TextBox txtName;
private System.Windows.Forms.Button btnDisplayName;
private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.Label lblMessage;
}
}
3.Form1.cs
//namespace
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;
//application namespace
namespace Demo_NameApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//display button click
private void btnDisplayName_Click(object sender, EventArgs e)
{
//take name entered by user and display messgae
lblMessage.Text = "Hello ," + txtName.Text+"!";
}
//Exit button click
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();//close application
}
}
}
======================================================
Output : Run application using F5 and will get the screen as shown below
Screen 1:
Screen 2:Enter name and click on button to display name
Write a C# Windows Form program that asks the user to enter a name (in a TextBox) and displays the following message (in...