Introduction
Windows.Forms are used to create powerful Windows-based applications. In this article, I will explain how to perform Arithmetic operations using Windows.Forms.
Windows.Forms are used to create powerful Windows-based applications. In this article, I will explain how to perform Arithmetic operations using Windows.Forms.
Step 1 - Start the Project
- Open Visual Studio-->File Menu --->New project.
- Choose Windows Form application.
- Start project as Windows Forms app 9.
Step 2 - Designer pages and their properties
Now, the corresponding designer page will be loaded and the following changes are done in the properties of the form application for performing arithmetic operations.
Now, the corresponding designer page will be loaded and the following changes are done in the properties of the form application for performing arithmetic operations.
- Maximize Box is set to False.
- Start Location may be central or Windows default location as required.
Step 3 - Control Functions
- Drag and Drop buttons, labels and text boxes from the toolbar.
- A button accepts clicks. In this project five buttons are used, that accept click events and perform actions in the user interface.
- In this project, three labels are used to display text on a form.
- Three text boxes are used - two of which are used to get user input and the remaining one is for displaying the result.
Step 4 - Coding for Button Click
ADD Button Click.
ADD Button Click.
- private void button2_Click(object sender, EventArgs e)
- {
- int num= int.Parse(textBox1.Text);
- int num2 = int.Parse(textBox2.Text);
- int sum = num + num2;
- textBox3.Text = sum.ToString();
- }
SUB Button Click.
- private void button3_Click(object sender, EventArgs e)
- {
- int num = int.Parse(textBox1.Text);
- int num2 = int.Parse(textBox2.Text);
- int sum = num - num2;
- textBox3.Text = sum.ToString();
- }


Kartik PawarPosted May 17, 2018, 6:17 AM
Nice article for beginners...