Question

You are to design this form by C#.

The submit button will display all the information in the output button. Example: "James, USA, Arizona. Age 52 Male. Knows C# and Java" (3 marks).

The clear button clears all the choices (2 marks).

Project 2 - 0 X User Details Name Gender address O Male O Female Age Computer Languages Al Kharj Riyadh Jeddah Medinah C++ Ja

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//Create this interface

Form1 groupBox2 group Box 1 label2 O radio Button1 label3 O radio Button2 label4 list Box 1 group Box 3 checkBox 1 checkBox2

//Change the name and text properties of controls

Project2 - o x Gender User Details Name O Male Address Female Age Ist Data Computer Languages C# C++ Java Submit Clear Output

//Form1.Designer.cs

namespace project_2
{
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.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.lstData = new System.Windows.Forms.ListBox();
this.btnSubmit = new System.Windows.Forms.Button();
this.btnClear = new System.Windows.Forms.Button();
this.txtOutput = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.txtName = new System.Windows.Forms.TextBox();
this.txtAddress = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.txtAge = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.rdbMale = new System.Windows.Forms.RadioButton();
this.rdbFemale = new System.Windows.Forms.RadioButton();
this.chkC_Sharp = new System.Windows.Forms.CheckBox();
this.chk_CPP = new System.Windows.Forms.CheckBox();
this.chkJava = new System.Windows.Forms.CheckBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.txtAge);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.txtAddress);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.txtName);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Location = new System.Drawing.Point(32, 22);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(200, 128);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "User Details";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.rdbFemale);
this.groupBox2.Controls.Add(this.rdbMale);
this.groupBox2.Location = new System.Drawing.Point(297, 22);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(200, 100);
this.groupBox2.TabIndex = 1;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Gender";
//
// groupBox3
//
this.groupBox3.Controls.Add(this.chkJava);
this.groupBox3.Controls.Add(this.chk_CPP);
this.groupBox3.Controls.Add(this.chkC_Sharp);
this.groupBox3.Location = new System.Drawing.Point(297, 156);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(200, 112);
this.groupBox3.TabIndex = 1;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Computer Languages";
//
// lstData
//
this.lstData.FormattingEnabled = true;
this.lstData.Location = new System.Drawing.Point(32, 156);
this.lstData.Name = "lstData";
this.lstData.Size = new System.Drawing.Size(120, 95);
this.lstData.TabIndex = 2;
//
// btnSubmit
//
this.btnSubmit.Location = new System.Drawing.Point(337, 274);
this.btnSubmit.Name = "btnSubmit";
this.btnSubmit.Size = new System.Drawing.Size(75, 23);
this.btnSubmit.TabIndex = 3;
this.btnSubmit.Text = "Submit";
this.btnSubmit.UseVisualStyleBackColor = true;
this.btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click);
//
// btnClear
//
this.btnClear.Location = new System.Drawing.Point(337, 303);
this.btnClear.Name = "btnClear";
this.btnClear.Size = new System.Drawing.Size(75, 23);
this.btnClear.TabIndex = 4;
this.btnClear.Text = "Clear";
this.btnClear.UseVisualStyleBackColor = true;
this.btnClear.Click += new System.EventHandler(this.btnClear_Click);
//
// txtOutput
//
this.txtOutput.Location = new System.Drawing.Point(104, 350);
this.txtOutput.Name = "txtOutput";
this.txtOutput.Size = new System.Drawing.Size(427, 20);
this.txtOutput.TabIndex = 5;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(29, 353);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(39, 13);
this.label1.TabIndex = 6;
this.label1.Text = "Output";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(7, 20);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(35, 13);
this.label2.TabIndex = 0;
this.label2.Text = "Name";
//
// txtName
//
this.txtName.Location = new System.Drawing.Point(88, 17);
this.txtName.Name = "txtName";
this.txtName.Size = new System.Drawing.Size(100, 20);
this.txtName.TabIndex = 1;
//
// txtAddress
//
this.txtAddress.Location = new System.Drawing.Point(88, 53);
this.txtAddress.Name = "txtAddress";
this.txtAddress.Size = new System.Drawing.Size(100, 20);
this.txtAddress.TabIndex = 3;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(7, 56);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(45, 13);
this.label3.TabIndex = 2;
this.label3.Text = "Address";
//
// txtAge
//
this.txtAge.Location = new System.Drawing.Point(88, 91);
this.txtAge.Name = "txtAge";
this.txtAge.Size = new System.Drawing.Size(100, 20);
this.txtAge.TabIndex = 5;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(7, 94);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(26, 13);
this.label4.TabIndex = 4;
this.label4.Text = "Age";
//
// rdbMale
//
this.rdbMale.AutoSize = true;
this.rdbMale.Location = new System.Drawing.Point(30, 30);
this.rdbMale.Name = "rdbMale";
this.rdbMale.Size = new System.Drawing.Size(48, 17);
this.rdbMale.TabIndex = 0;
this.rdbMale.TabStop = true;
this.rdbMale.Text = "Male";
this.rdbMale.UseVisualStyleBackColor = true;
//
// rdbFemale
//
this.rdbFemale.AutoSize = true;
this.rdbFemale.Location = new System.Drawing.Point(30, 56);
this.rdbFemale.Name = "rdbFemale";
this.rdbFemale.Size = new System.Drawing.Size(59, 17);
this.rdbFemale.TabIndex = 1;
this.rdbFemale.TabStop = true;
this.rdbFemale.Text = "Female";
this.rdbFemale.UseVisualStyleBackColor = true;
//
// chkC_Sharp
//
this.chkC_Sharp.AutoSize = true;
this.chkC_Sharp.Location = new System.Drawing.Point(6, 19);
this.chkC_Sharp.Name = "chkC_Sharp";
this.chkC_Sharp.Size = new System.Drawing.Size(40, 17);
this.chkC_Sharp.TabIndex = 0;
this.chkC_Sharp.Text = "C#";
this.chkC_Sharp.UseVisualStyleBackColor = true;
//
// chk_CPP
//
this.chk_CPP.AutoSize = true;
this.chk_CPP.Location = new System.Drawing.Point(6, 51);
this.chk_CPP.Name = "chk_CPP";
this.chk_CPP.Size = new System.Drawing.Size(45, 17);
this.chk_CPP.TabIndex = 1;
this.chk_CPP.Text = "C++";
this.chk_CPP.UseVisualStyleBackColor = true;
//
// chkJava
//
this.chkJava.AutoSize = true;
this.chkJava.Location = new System.Drawing.Point(6, 83);
this.chkJava.Name = "chkJava";
this.chkJava.Size = new System.Drawing.Size(49, 17);
this.chkJava.TabIndex = 2;
this.chkJava.Text = "Java";
this.chkJava.UseVisualStyleBackColor = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(543, 391);
this.Controls.Add(this.label1);
this.Controls.Add(this.txtOutput);
this.Controls.Add(this.btnClear);
this.Controls.Add(this.btnSubmit);
this.Controls.Add(this.lstData);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Name = "Form1";
this.Text = "Project2";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox txtAge;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox txtAddress;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txtName;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.RadioButton rdbFemale;
private System.Windows.Forms.RadioButton rdbMale;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.CheckBox chkJava;
private System.Windows.Forms.CheckBox chk_CPP;
private System.Windows.Forms.CheckBox chkC_Sharp;
private System.Windows.Forms.ListBox lstData;
private System.Windows.Forms.Button btnSubmit;
private System.Windows.Forms.Button btnClear;
private System.Windows.Forms.TextBox txtOutput;
private System.Windows.Forms.Label label1;
}
}

//====================================

//Form1.cs

using System;

using System.Windows.Forms;

namespace project_2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//disable txtOutput
txtOutput.ReadOnly = true;
}

private void btnClear_Click(object sender, EventArgs e)
{
//clear text boxes
txtName.Clear();
txtAddress.Clear();
txtAge.Clear();
txtOutput.Clear();
//deselect radio buttons
rdbMale.Checked = false;
rdbFemale.Checked = false;
//deselect checkBoxes
chkC_Sharp.Checked = false;
chk_CPP.Checked = false;
chkJava.Checked = false;
}

private void btnSubmit_Click(object sender, EventArgs e)
{
String output = txtName.Text + ", " + txtAddress.Text + ", Age " + txtAge.Text;
if (rdbMale.Checked)
output += " Male.";
if (rdbFemale.Checked)
output += " Female.";
output += " Knows ";
if (chkC_Sharp.Checked)
output += chkC_Sharp.Text+" ";
if (chkJava.Checked)
output += chkJava.Text + " ";
if (chk_CPP.Checked)
output += chk_CPP.Text+" ";

txtOutput.Text = output;
if(!txtName.Text.Equals(""))
lstData.Items.Add(txtName.Text);
  
}
}
}

//Output

Project2 ох Gender User Details Name Tim Male Female Address Arizona Age 23 Computer Languages Java Submit Clear Output Tim ,

//If you need any help regarding this solution...... please leave a comment..... thanks

Add a comment
Know the answer?
Add Answer to:
You are to design this form by C#. The submit button will display all the information...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT