Question

Create C# project of type Windows Forms Application titled your name: 1. Change the form title to YourName_Smart Convertor

I need the whole and correct code

Form1.cs

Form1.Designer.cs

Form2.cs

Form2.Designer.cs

program.cs

everything in details

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

All the Designer and Form Logic files are given below within their respective tables. You are required to create the Project and add a 2nd Windows form named Conversion_Summary.cs and then copy the below codes and paste into their respective files and save. And then finally you can run the application to test it.

*************************************** MAIN FORM ******************************************

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

// Method to execute when convert button is clicked
private void btnConvert_Click(object sender, EventArgs e)
{
// check whether distance textfield is filled or not
if (tb_distance.Text.Equals(""))
MessageBox.Show("Please enter the distance.", "Message");
else
{
double distance;
// try to parse the distance to double
if ( ! double.TryParse(tb_distance.Text, out distance))
MessageBox.Show("Please enter the distance in numeric format", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
else
displayConvertedData(distance);
}
}

// helper method to convert entered distance to meters
private void displayConvertedData(double distance)
{
double distM = 0;
// create an object of Conversion_Summary form
Conversion_Summary formResult = new Conversion_Summary();

// check if centi meter radio button is checked
if (rb_cm.Checked == true)
{
distM = 0.01 * distance;
// change the result lable to display the converted distance
// in Conversion_Summary form
formResult.lbl_result.Text = "Distance in meter = " + distM;
formResult.Show();
}

// check if kilo meter radio button is checked
else if (rb_km.Checked == true)
{
distM = 1000 * distance;
formResult.lbl_result.Text = "Distance in meter = " + distM;
formResult.Show();
}

// check if inch radio button is checked
else if (rb_inch.Checked == true)
{
distM = 0.0254 * distance;
formResult.lbl_result.Text = "Distance in meter = " + distM;
formResult.Show();
}

// else display the message to select the unit radio button, if none of the
// radio button is selected
else
MessageBox.Show("Please select the unit", "Message");
}
}
}

Form1.Designer.cs

namespace Distance_Converter
{
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.lbl_distance = new System.Windows.Forms.Label();
this.tb_distance = new System.Windows.Forms.TextBox();
this.grpbox_unit = new System.Windows.Forms.GroupBox();
this.rb_inch = new System.Windows.Forms.RadioButton();
this.rb_km = new System.Windows.Forms.RadioButton();
this.rb_cm = new System.Windows.Forms.RadioButton();
this.btnConvert = new System.Windows.Forms.Button();
this.picturebox1 = new System.Windows.Forms.PictureBox();
this.grpbox_unit.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picturebox1)).BeginInit();
this.SuspendLayout();
//
// lbl_distance
//
this.lbl_distance.AutoSize = true;
this.lbl_distance.Font = new System.Drawing.Font("Calibri", 23.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl_distance.Location = new System.Drawing.Point(3, 9);
this.lbl_distance.Name = "lbl_distance";
this.lbl_distance.Size = new System.Drawing.Size(188, 58);
this.lbl_distance.TabIndex = 0;
this.lbl_distance.Text = "Distance";
//
// tb_distance
//
this.tb_distance.Location = new System.Drawing.Point(197, 24);
this.tb_distance.Name = "tb_distance";
this.tb_distance.Size = new System.Drawing.Size(100, 26);
this.tb_distance.TabIndex = 1;
//
// grpbox_unit
//
this.grpbox_unit.Controls.Add(this.rb_inch);
this.grpbox_unit.Controls.Add(this.rb_km);
this.grpbox_unit.Controls.Add(this.rb_cm);
this.grpbox_unit.Font = new System.Drawing.Font("Calibri", 23F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.grpbox_unit.Location = new System.Drawing.Point(25, 90);
this.grpbox_unit.Name = "grpbox_unit";
this.grpbox_unit.Size = new System.Drawing.Size(166, 248);
this.grpbox_unit.TabIndex = 2;
this.grpbox_unit.TabStop = false;
this.grpbox_unit.Text = "Unit";
//
// rb_inch
//
this.rb_inch.AutoSize = true;
this.rb_inch.Location = new System.Drawing.Point(26, 177);
this.rb_inch.Name = "rb_inch";
this.rb_inch.Size = new System.Drawing.Size(128, 60);
this.rb_inch.TabIndex = 4;
this.rb_inch.TabStop = true;
this.rb_inch.Text = "Inch";
this.rb_inch.UseVisualStyleBackColor = true;
//
// rb_km
//
this.rb_km.AutoSize = true;
this.rb_km.Location = new System.Drawing.Point(26, 118);
this.rb_km.Name = "rb_km";
this.rb_km.Size = new System.Drawing.Size(109, 60);
this.rb_km.TabIndex = 3;
this.rb_km.TabStop = true;
this.rb_km.Text = "Km";
this.rb_km.UseVisualStyleBackColor = true;
//
// rb_cm
//
this.rb_cm.AutoSize = true;
this.rb_cm.Location = new System.Drawing.Point(26, 61);
this.rb_cm.Name = "rb_cm";
this.rb_cm.Size = new System.Drawing.Size(111, 60);
this.rb_cm.TabIndex = 2;
this.rb_cm.TabStop = true;
this.rb_cm.Text = "Cm";
this.rb_cm.UseVisualStyleBackColor = true;
//
// btnConvert
//
this.btnConvert.ForeColor = System.Drawing.Color.Blue;
this.btnConvert.Location = new System.Drawing.Point(234, 275);
this.btnConvert.Name = "btnConvert";
this.btnConvert.Size = new System.Drawing.Size(210, 63);
this.btnConvert.TabIndex = 5;
this.btnConvert.Text = "Convert to meter";
this.btnConvert.UseVisualStyleBackColor = true;
this.btnConvert.Click += new System.EventHandler(this.btnConvert_Click);
//
// picturebox1
//
this.picturebox1.Image = global::Distance_Converter.Properties.Resources.converter;
this.picturebox1.Location = new System.Drawing.Point(303, 25);
this.picturebox1.Name = "picturebox1";
this.picturebox1.Size = new System.Drawing.Size(114, 108);
this.picturebox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.picturebox1.TabIndex = 4;
this.picturebox1.TabStop = false;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(248)))), ((int)(((byte)(220)))));
this.ClientSize = new System.Drawing.Size(470, 350);
this.Controls.Add(this.picturebox1);
this.Controls.Add(this.btnConvert);
this.Controls.Add(this.grpbox_unit);
this.Controls.Add(this.tb_distance);
this.Controls.Add(this.lbl_distance);
this.Name = "Form1";
this.Text = "Smart Converter";
this.grpbox_unit.ResumeLayout(false);
this.grpbox_unit.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.picturebox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.Label lbl_distance;
private System.Windows.Forms.TextBox tb_distance;
private System.Windows.Forms.GroupBox grpbox_unit;
private System.Windows.Forms.RadioButton rb_inch;
private System.Windows.Forms.RadioButton rb_km;
private System.Windows.Forms.RadioButton rb_cm;
private System.Windows.Forms.Button btnConvert;
private System.Windows.Forms.PictureBox picturebox1;
}
}

**************************** CONVERSION SUMMARY FORM ************************************

Conversion_Summary.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 Distance_Converter
{
public partial class Conversion_Summary : Form
{
public Conversion_Summary()
{
InitializeComponent();
}
}
}

Conversion_Summary.Designer.cs

namespace Distance_Converter
{
partial class Conversion_Summary
{
/// <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.lbl_result = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// lbl_result
//
this.lbl_result.AutoSize = true;
this.lbl_result.Font = new System.Drawing.Font("Microsoft Sans Serif", 25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl_result.Location = new System.Drawing.Point(56, 88);
this.lbl_result.Name = "lbl_result";
this.lbl_result.Size = new System.Drawing.Size(315, 58);
this.lbl_result.TabIndex = 0;
this.lbl_result.Text = "Result Label";
//
// Conversion_Summary
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(806, 261);
this.Controls.Add(this.lbl_result);
this.Name = "Conversion_Summary";
this.Text = "Conversion_Summary";
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

public System.Windows.Forms.Label lbl_result;
}
}

Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Distance_Converter
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

Important Note: The Conversion_Summary.cs and Program.cs code file need not to be changed in the Project, they are automatically generated and no changes is done. I Have posted the codes because you asked in the question.

Project Screenshot

Solution Explorer + X Conversion_Summary.cs Conversion_Summary.Designer.cs Program.cs Form1.cs Conversion_Summary.cs (Design)

Output

Smart Converter x Distance Unit o Cm o Km Inch O Convert to meter

Smart Converter X Distance Unit o Cm o Km o Inch Convert to meter X Message Please enter the distance. OK

Smart Converter Х Distance Unit o Cm o Km o Inch Convert to meter Error X x Please enter the distance in numeric format OK

Smart Converter Х Distance 2.75 Unit o Cm o Km o Inch Convert to meter Conversion_Summary X Distance in meter = 2750

X Smart Converter Distance 2.75 Unit o Cm o Km o Inch Convert to meter Conversion_Summary Х Distance in meter = 0.0275

Smart Converter Х Distance 2.75 Unit o Cm o Km o Inch Convert to meter Conversion_Summary Х Distance in meter = 0.06985

Please mention your doubts within the comments section and kindly give a thumbs up if you liked the Solution.

Add a comment
Know the answer?
Add Answer to:
I need the whole and correct code Form1.cs Form1.Designer.cs Form2.cs Form2.Designer.cs program.cs everything in details Create...
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
  • 1. Create a Java application that will change the appearance of a string as shown in...

    1. Create a Java application that will change the appearance of a string as shown in the picture. 2. The program will include a panel, label, checkboxes, radio buttons, and list. 3. To change color, set up 4 radio buttons in a button group. The colors are Black, Red, Green, and Blue to be selected. The default color is Black. 4. To change the font size, set up a list. The sizes are 18, 26, 38, and 56 to be...

  • MyMenuFrame.java, MyMenuFrameTest.java, a. The title of the frame is “MyNotepad”. b. Create and add border layout....

    MyMenuFrame.java, MyMenuFrameTest.java, a. The title of the frame is “MyNotepad”. b. Create and add border layout. c. Create a text area to display contents. Add the text area to the center of the border layout. d. Create a menu bar. e. Create a file menu. Set mnemonic for file menu. It is “F”. File menu includes three menu items. f. Add a separator between each menu item in the file menu. i. Open    1. Add a short cut for...

  • Create two classes following the model shown in Chapter 19. Assuming your data form's subject is ...

    Here's the pizza example layout.Need Help with this program. Java ser interface: Here are the groupings trom the pizza u Size Pepperoni Anchovies Smal edium Large Your Price: Create two classes following the model shown in Chapter 19. Assuming your data form's subject is X (though l expect better names), you need to provide the following classes: 1. XFormFrame, as a subclass of JFrame, responsible for creating and operating the form 2. XFormViewer, your main program responsible for creating the...

  • I NEED SOME HELP WITH THIS PLEASE :) 1. Create a data entry form on one...

    I NEED SOME HELP WITH THIS PLEASE :) 1. Create a data entry form on one of your web pages for visitors who want to be added to your mailing list. Include one of each of the following input elements*: Text <input type="text".... • Tel <input type="tel".... . Email <input type="email"... Date <input type="date"... . A set of radio buttons <input type="radio"... • A set of check boxes <input type="checkbox"... • A select element with options <select>.....</select> (do NOT add...

  • Visual Studio Code C# Well Document everyline saying what the code does. Include designer code and...

    Visual Studio Code C# Well Document everyline saying what the code does. Include designer code and .cscode Extra 6-1 Create a simple calculator In this exercise, you'l1 create a form that accepts two operands and an operator from the user and then performs the requested operation. Simple Calculator Operand 1: 86 Operator Operand 2 11.11 Resut 7.7408 1. Start a new project named SimpleCalculator in the Extra Exercises Chapter 06SimpleCalculator directory 2. Add labels, text boxes, and buttons to the...

  • In this exercise, you’ll add code to a form that converts the value the user enters...

    In this exercise, you’ll add code to a form that converts the value the user enters based on the selected conversion type. The application should handle the following conversions: 1. Open the Conversions project. Display the code for the form, and notice the rectangular array whose rows contain the value to be displayed in the combo box, the text for the labels that identify the two text boxes, and the multiplier for the conversion as shown above. Note: An array...

  • How can I add this function to my C# code?: Validate that if the user clicks...

    How can I add this function to my C# code?: Validate that if the user clicks the “OK” button, a “Seating Category” is selected, and at least one ticket is being purchased. If not, pop-up a dialog box asking the user to enter the needed data for the transaction. What we want to avoid is depicted in See Figure 3. Figure 3: This code asks for a seating category to be selected, how many tickets to be purchased, and if...

  • I. User Interface Create a JavaFX application with a graphical user interface (GUI) based on the...

    I. User Interface Create a JavaFX application with a graphical user interface (GUI) based on the attached “GUI Mock-Up”. Write code to display each of the following screens in the GUI: A. A main screen, showing the following controls: • buttons for “Add”, “Modify”, “Delete”, “Search” for parts and products, and “Exit” • lists for parts and products • text boxes for searching for parts and products • title labels for parts, products, and the application title B. An add...

  • The Gui has all the right buttons, but from there i get lost. I need to...

    The Gui has all the right buttons, but from there i get lost. I need to know whats wrong with my assignment can someone please help. The code I have so far is listed below, could you please show me the errors in my code. PYTHON Create the GUI(Graphical User Interface). Use tkinter to produce a form that looks much like the following. It should have these widgets. Temperature Converter GUI Enter a temperature (Entry box)                 Convert to Fahrenheit...

  • Project 2 Description Create a Visual C# project that when an employee's biweekly sales amount is...

    Project 2 Description Create a Visual C# project that when an employee's biweekly sales amount is entered and the Calculate button is pressed, the gross pay, deductions, and net pay will be displayed. Each employee will receive a base pay of $1200 plus a sales commission of 8% of sales. Once the net pay has been calculated, display the budget amount for each category listed below based on the percentages given.         base pay = $1200; use a named...

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