You are on page 1of 20

Code Behind Form1

namespace calculator
{
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.label2 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.button6 = new System.Windows.Forms.Button();
this.textBox3 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 20);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(66, 13);
this.label1.TabIndex = 0;
this.label1.Text = "First Number";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 48);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(84, 13);
this.label2.TabIndex = 1;
this.label2.Text = "Second Number";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(117, 17);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 2;
//
// textBox2

//
this.textBox2.Location = new System.Drawing.Point(117, 48);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 3;
//
// button1
//
this.button1.Location = new System.Drawing.Point(93, 192);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 5;
this.button1.Text = "Sub";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.DialogResult =
System.Windows.Forms.DialogResult.Cancel;
this.button2.Location = new System.Drawing.Point(117, 243);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 6;
this.button2.Text = "Close";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(12, 192);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 7;
this.button3.Text = "add";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.Location = new System.Drawing.Point(252, 192);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(75, 23);
this.button4.TabIndex = 8;
this.button4.Text = "Div";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button5
//
this.button5.Location = new System.Drawing.Point(171, 192);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(75, 23);
this.button5.TabIndex = 9;
this.button5.Text = "Mul";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);

//
// button6
//
this.button6.Location = new System.Drawing.Point(36, 243);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(75, 23);
this.button6.TabIndex = 10;
this.button6.Text = "Clear";
this.button6.UseVisualStyleBackColor = true;
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(117, 74);
this.textBox3.Multiline = true;
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(105, 112);
this.textBox3.TabIndex = 11;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(22, 120);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(37, 13);
this.label3.TabIndex = 12;
this.label3.Text = "Result";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.button2;
this.ClientSize = new System.Drawing.Size(410, 266);
this.Controls.Add(this.label3);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.button6);
this.Controls.Add(this.button5);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;

private
private
private
private
private
private
private
private
private
private
}

System.Windows.Forms.TextBox textBox1;
System.Windows.Forms.TextBox textBox2;
System.Windows.Forms.Button button1;
System.Windows.Forms.Button button2;
System.Windows.Forms.Button button3;
System.Windows.Forms.Button button4;
System.Windows.Forms.Button button5;
System.Windows.Forms.Button button6;
System.Windows.Forms.TextBox textBox3;
System.Windows.Forms.Label label3;

Business Logic:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace calculator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e)
{
textBox3.Text = Convert.ToString("addition of "+textBox1.Text+"
and "+textBox2.Text+" is"+(int.Parse(textBox1.Text)
+int.Parse(textBox2.Text)));
}
private void button1_Click(object sender, EventArgs e)
{
textBox3.Text = Convert.ToString("substraction of " +
textBox1.Text + " and " + textBox2.Text + " is" + (int.Parse(textBox1.Text) int.Parse(textBox2.Text)));
}
private void button5_Click(object sender, EventArgs e)
{
textBox3.Text = Convert.ToString("product of " + textBox1.Text + "
and " + textBox2.Text + " is" + (int.Parse(textBox1.Text) *
int.Parse(textBox2.Text)));
}
private void button4_Click(object sender, EventArgs e)
{
textBox3.Text = Convert.ToString("division of " + textBox1.Text +
" and " + textBox2.Text + " is" + (int.Parse(textBox1.Text) /
int.Parse(textBox2.Text)));

}
private void button6_Click(object sender, EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
}
}

Program.cs
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Windows.Forms;

namespace WindowsFormsApplication1
{
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());
}
}
}

Form1.cs

using
using
using
using
using
using
using
using

System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
textBox3.Text = Convert.ToString("addition of " + textBox1.Text +
" and " + textBox2.Text + " is" + (int.Parse(textBox1.Text) +
int.Parse(textBox2.Text)));
}
private void button2_Click(object sender, EventArgs e)
{
textBox3.Text = Convert.ToString("substraction of " +
textBox1.Text + " and " + textBox2.Text + " is" + (int.Parse(textBox1.Text) int.Parse(textBox2.Text)));
}
private void button3_Click(object sender, EventArgs e)
{
textBox3.Text = Convert.ToString("product of " + textBox1.Text + "
and " + textBox2.Text + " is" + (int.Parse(textBox1.Text) *
int.Parse(textBox2.Text)));
}
private void button4_Click(object sender, EventArgs e)
{
textBox3.Text = Convert.ToString("division of " + textBox1.Text +
" and " + textBox2.Text + " is" + (int.Parse(textBox1.Text) /
int.Parse(textBox2.Text)));
}
private void button6_Click(object sender, EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
}
private void button5_Click(object sender, EventArgs e)
{
this.Close();

}
}
}

Form1.desiner.cs
namespace WindowsFormsApplication1
{
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.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.button6 = new System.Windows.Forms.Button();
this.label5 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//

this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(240, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(98, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Simple Calculations";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(37, 39);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(66, 13);
this.label2.TabIndex = 1;
this.label2.Text = "First Number";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(37, 69);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(84, 13);
this.label3.TabIndex = 2;
this.label3.Text = "Second Number";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(37, 107);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(37, 13);
this.label4.TabIndex = 3;
this.label4.Text = "Result";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(126, 36);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(402, 20);
this.textBox1.TabIndex = 4;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(126, 69);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(402, 20);
this.textBox2.TabIndex = 5;
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(126, 100);
this.textBox3.Multiline = true;
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(402, 78);
this.textBox3.TabIndex = 6;
//
// button1

//
this.button1.Location = new System.Drawing.Point(28, 212);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 48);
this.button1.TabIndex = 7;
this.button1.Text = "Add";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(151, 212);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 48);
this.button2.TabIndex = 8;
this.button2.Text = "Sub";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(287, 208);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 52);
this.button3.TabIndex = 9;
this.button3.Text = "Prod";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.Location = new System.Drawing.Point(426, 208);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(75, 52);
this.button4.TabIndex = 10;
this.button4.Text = "Quot";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button5
//
this.button5.Location = new System.Drawing.Point(297, 330);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(75, 63);
this.button5.TabIndex = 11;
this.button5.Text = "exit";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// button6
//
this.button6.Location = new System.Drawing.Point(151, 330);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(75, 63);
this.button6.TabIndex = 12;
this.button6.Text = "Clear";
this.button6.UseVisualStyleBackColor = true;

this.button6.Click += new System.EventHandler(this.button6_Click);


//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(492, 441);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(35, 13);
this.label5.TabIndex = 13;
this.label5.Text = "Rahul";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(664, 497);
this.Controls.Add(this.label5);
this.Controls.Add(this.button6);
this.Controls.Add(this.button5);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion

}
}

private
private
private
private
private
private
private
private
private
private
private
private
private
private

System.Windows.Forms.Label label1;
System.Windows.Forms.Label label2;
System.Windows.Forms.Label label3;
System.Windows.Forms.Label label4;
System.Windows.Forms.TextBox textBox1;
System.Windows.Forms.TextBox textBox2;
System.Windows.Forms.TextBox textBox3;
System.Windows.Forms.Button button1;
System.Windows.Forms.Button button2;
System.Windows.Forms.Button button3;
System.Windows.Forms.Button button4;
System.Windows.Forms.Button button5;
System.Windows.Forms.Button button6;
System.Windows.Forms.Label label5;

You might also like