Question #56267

in c# Create a graphical user interface that allows the users to enter personal information such as their names, e-mail addresses, and phone numbers. Include a menu that provides a minimum of four features. The first displays the information entered by the user in a message box. The second clears the entries so that new values can be entered, the third menu option displays information about the application such as who developed it and what version it is. Another menu option closes the application. Be creative and be sure to produce an aesthetically pleasing design using options from the Format menu if you are using Visual Studio.

Expert's answer

Here is the processed document with the code blocks fixed and formatted:

Answer on Question #56267-Programming-C#

Form1.cs


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 PersonInformation
{
    public partial class Form1 : Form
    {
        const string _empty = "";
        public Form1()
        {
            InitializeComponent();
        }
        private void button3_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
        private void button2_Click(object sender, EventArgs e)
        {
            NameTb.Text = _empty;
            LastNameTb.Text = _empty;
            EmailTb.Text = _empty;
            PhoneNumberTb.Text = _empty;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            StringBuilder info = new StringBuilder();
            info.AppendLine(string.Format("Name: {0}", NameTb.Text != _empty? NameTb.Text: "empty"));
            info.AppendLine(string.Format("Last Name: {0}", LastNameTb.Text != _empty ? LastNameTb.Text : "empty"));
            info.AppendLine(string.Format("Email: {0}", EmailTb.Text != _empty ? EmailTb.Text : "empty"));
            info.AppendLine(string.Format("Phone: {0}", PhoneNumberTb.Text != _empty ? PhoneNumberTb.Text : "empty"));
            MessageBox.Show(info.ToString(), "User information");
        }
        private void aboutProgramToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string devName = "Ivan Tsurkan";
            string version = "1.0";
            StringBuilder info = new StringBuilder();
            info.AppendLine(string.Format("Developer: {0}", devName));
            info.AppendLine(string.Format("Last Name: {0}", version));
            MessageBox.Show(info.ToString(), "About program");
        }
    }
}


Form1.Designer.cs


namespace PersonInformation
{
    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.label1 = new System.Windows.Forms.Label();
            this.NameTb = new System.Windows.Forms.TextBox();
            this.LastNameTb = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.EmailTb = new System.Windows.Forms.TextBox();
            this.label3 = new System.Windows.Forms.Label();
            this.PhoneNumberTb = new System.Windows.Forms.TextBox();
            this.label4 = new System.Windows.Forms.Label();
            this.menuStrip1 = new System.Windows.Forms.MenuStrip();
            this.menuToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.displayInformationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.clearFieldsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.aboutProgramToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.ShowInfoBtn = new System.Windows.Forms.Button();
            this.CancelBtn = new System.Windows.Forms.Button();
            this.ViewStrip1.SuspendLayout();
            this.SuspendLayout();
            // label1
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(72, 45);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(35, 13);
            this.label1.TabIndex = 0;
            this.label1.Text = "Name";
            // NameTb
            this.NameTb.Location = new System.Drawing.Point(128, 42);
            this.NameTb.Name = "NameTb";
            this.NameTb.Size = new System.Drawing.Size(164, 20);
            this.NameTb.TabIndex = 1;
            // LastNameTb
            this.LastNameTb.Location = new System.Drawing.Point(128, 79);
            this.LastNameTb.Name = "LastNameTb";
            this.LastNameTb.Size = new System.Drawing.Size(164, 20);
            this.LastNameTb.TabIndex = 3;
            // label2
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(46, 82);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(58, 13);
            this.label2.TabIndex = 2;
            this.label2.Text = "Last Name";
            // EmailTb
            this.EmailTb.Location = new System.Drawing.Point(128, 118);
            this.EmailTb.Name = "EmailTb";
            this.EmailTb.Size = new System.Drawing.Size(164, 20);
            this.EmailTb.TabIndex = 5;
            // label3
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(72, 125);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(32, 13);
            this.label3.TabIndex = 4;
            this.label3.Text = "Email";
            // PhoneNumberTb
            this.PhoneNumberTb.Location = new System.Drawing.Point(128, 158);
            this.PhoneNumberTb.Name = "PhoneNumberTb";
            this.PhoneNumberTb.Size = new System.Drawing.Size(164, 20);
            this.PhoneNumberTb.TabIndex = 7;
            // label4
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(29, 161);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(78, 13);
            this.label4.TabIndex = 6;
            this.label4.Text = "Phone Number";
            // menuStrip1
            this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.menuToolStripMenuItem});
            this.menuStrip1.Location = new System.Drawing.Point(0, 0);
            this.menuStrip1.Name = "menuStrip1";
            this.menuStrip1.Size = new System.Drawing.Size(335, 24);
            this.menuStrip1.TabIndex = 8;
            this.menuStrip1.Text = "menuStrip1";
            // menuToolStripMenuItem
            this.menuToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.displayInformationToolStripMenuItem,
            this.clearFieldsToolStripMenuItem,
            this.aboutProgramToolStripMenuItem,
            this.exitToolStripMenuItem});
            this.menuToolStripMenuItem.Name = "menuToolStripMenuItem";
            this.menuToolStripMenuItem.Size = new System.Drawing.Size(50, 20);
            this.menuToolStripMenuItem.Text = "Menu";
            // displayInformationToolStripMenuItem
            this.displayInformationToolStripMenuItem.Name = "displayInformationToolStripMenuItem";
            this.displayInformationToolStripMenuItem.Size = new System.Drawing.Size(206, 22);
            this.displayInformationToolStripMenuItem.Text = "Display user information";
            this.displayInformationToolStripMenuItem.Click += new System.EventHandler(this.button1_Click);
            // clearFieldsToolStripMenuItem
            this.clearFieldsToolStripMenuItem.Name = "clearFieldsToolStripMenuItem";
            this.clearFieldsToolStripMenuItem.Size = new System.Drawing.Size(206, 22);
            this.clearFieldsToolStripMenuItem.Text = "Clear fields";
            this.clearFieldsToolStripMenuItem.Click += new System.EventHandler(this.button2_Click);
            // aboutProgramToolStripMenuItem
            this.aboutProgramToolStripMenuItem.Name = "aboutProgramToolStripMenuItem";
            this.aboutProgramToolStripMenuItem.Size = new System.Drawing.Size(206, 22);
            this.aboutProgramToolStripMenuItem.Text = "About program";
            this.aboutProgramToolStripMenuItem.Click += new System.EventHandler(this.aboutProgramToolStripMenuItem_Click);
            // exitToolStripMenuItem
            this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
            this.exitToolStripMenuItem.Size = new System.Drawing.Size(206, 22);
            this.exitToolStripMenuItem.Text = "Exit";
            this.exitToolStripMenuItem.Click += new System.EventHandler(this.button3_Click);
            // ShowInfoBtn
            this.ShowInfoBtn.Location = new System.Drawing.Point(29, 206);
            this.ShowInfoBtn.Name = "ShowInfoBtn";
            this.ShowInfoBtn.Size = new System.Drawing.Size(75, 23);
            this.ShowInfoBtn.TabIndex = 9;
            this.ShowInfoBtn.Text = "Show";
            this.ShowInfoBtn.UseVisualStyleBackColor = true;
            this.ShowInfoBtn.Click += new System.EventHandler(this.button1_Click);
            // CancelBtn
            this.CancelBtn.Location = new System.Drawing.Point(128, 206);
            this.CancelBtn.Name = "CancelBtn";
            this.CancelBtn.Size = new System.Drawing.Size(75, 23);
            this.CancelBtn.TabIndex = 10;
            this.CancelBtn.Text = "Cancel";
            this.CancelBtn.UseVisualStyleBackColor = true;
            this.CancelBtn.Click += new System.EventHandler(this.button2_Click);
            // CloseBtn
            this.CloseBtn.Location = new System.Drawing.Point(233, 206);
            this.CloseBtn.Name = "CloseBtn";
            this.CloseBtn.Size = new System.Drawing.Size(75, 23);
            this.CloseBtn.TabIndex = 11;
            this.CloseBtn.Text = "Close";
            this.CloseBtn.UseVisualStyleBackColor = true;
            this.CloseBtn.Click += new System.EventHandler(this.button3_Click);
            // Form1
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(335, 254);
            this.Controls.Add(this.CloseBtn);
            this.Controls.Add(this.CancelBtn);
            this.Controls.Add(this.ShowInfoBtn);
            this.Controls.Add(this.PhoneNumberTb);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.EmailTb);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.LastNameTb);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.NameTb);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.menuStrip1);
            this.MainMenuStrip = this.menuStrip1;
            this.Name = "Form1";
            this.Text = "Form1";
            this.menuStrip1.ResumeLayout(false);
            this.menuStrip1.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();
        #endregion
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.TextBox PhoneNumberTbNameTb;
        private System.Windows.Forms.TextBox LastNameTb;
        private System.Windows.Forms.TextBox NameTb;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.TextBox EmailTb;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.TextBox PhoneNumberTb;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.MenuStrip menuStrip1;
        private System.Windows.Forms.ToolStripMenuItem menuToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem displayInformationToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem clearFieldsToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem aboutProgramToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
        private System.Windows.Forms.Button ShowInfoBtn;
        private System.Windows.Forms.Button CancelBtn;
        private System.Windows.Forms.Button CloseBtn;
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS