SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
Demo Projects
• Simple Calculator
• Student Progress Report
What will you learn?
• Designing simple user
• Changing properties of controls
• Writing event handler for button
• Using following controls:
o Labels
o Textboxes
o Buttons
o Group-box
Windows Forms for Beginners
Student Progress Report
ser interface
Changing properties of controls
Writing event handler for button’s click event
controls:
Bhushan Mulmule
bhushan.mulmule@gmail.com
www.dotnetvideotutorial.com
Windows Forms for Beginners
Part 1
Bhushan Mulmule
bhushan.mulmule@gmail.com
www.dotnetvideotutorial.com
Windows Forms for Beginners
Project 1: Basic Calculator
• Create New Windows Form Application
• Step 1: Design User Interface
• Step 2: Change Properties of labels, textboxes and buttons
• Step 3: Write Code for buttons
Step 1: Design UI as follow:
Labels
Arrange No1, No2 and
Result labels to align
right walls
Textboxes
User should not able
to type in result
textbox.
In next example to
show output we will
use labels
Buttons
www.dotnetvideotutorial.com
Step 2: Set properties of controls as follow:
Control Name Text Readonly
Form frmBasicCalcii Basic
Calculator
Labels No need to change
Names of labels at left
hand side
Basic
Calculator
Number 1:
Number 2:
Result:
TextBoxes txtNo1
txtNo2
txtResult True
Buttons btnPlus +
btnMinus -
btnMul *
btnDiv /
btnReset Reset
btnExit Exit
Step 3: Add event handlers for buttons
1. Double click on Plus button and code it as follow:
private void btnPlus_Click(object sender, EventArgs e)
{
int no1, no2, result;
no1 = Convert.ToInt32(txtNo1.Text);
no2 = Convert.ToInt32(txtNo2.Text);
result = no1 + no2;
txtResult.Text = result.ToString();
}
Note: Write similar code for minus, multiplication and division.
www.dotnetvideotutorial.com
2. Double click Reset button and write code as follow:
private void btnClear_Click(object sender, EventArgs e)
{
//txtNo1.Text = "";
txtNo1.Clear();
txtNo2.Clear();
txtResult.Clear();
txtNo1.Focus();
}
3. Double click Exit button and write code as follow:
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
4. Application is ready execute and test.
Project 2: Student Progress Report
Step 1: Design UI And Change Properties as shown in callouts
(Please use common sense☺☺☺☺)
• Change Title Label Font size property to make it large
• No need to change Name property of labels at left-hand side as not used in
code
• Change only Text property of labels as shown in image
• Change names for all textboxes as specified in callouts respectively
• Change names for Right hand side output labels for Total, Percentage,
Division and Total.
• Do not change names of left hand side total, percentage, division and total
labels
• To change looks of right hand side output labels change AutoSize: False,
BackColor: White, BorderStyle: FixedSingle, Text: Blank
• Change only Text property of Group-box.
2 Textboxes
Name: txtRollNo,
txtName
5 TextBoxes:
Name: txtEng, txtMar, txtHindi,
txtMaths, txtScience
3 Buttons:
Name: btnOK, btnNew, btnExit
Text: OK, New, Exit
2 Groupbox:
Text: Scores,
Result
11 Labels:
Text: RollNo,
Name,
English,
Marathi,
Hindi, Math,
Science,
Total,
Percentage,
Division,
Result
4 Labels:
To Display output for Total, Percentage,
Division and Result use Labels.
To change looks of these four labels set
following properties:
AutoSize: False
BackColor: White
BorderStyle: FixedSingle
Text: Blank
Name: lblTotal, lblPer, lblDiv, lblResult
www.dotnetvideotutorial.com
Step 3: Add event handlers for buttons
• Double click on OK and code it as follow:
private void btnOK_Click(object sender, EventArgs e)
{
int m1, m2, m3, m4, m5, total;
float per;
string div="", result="";
m1 = Convert.ToInt32(txtEng.Text);
m2 = Convert.ToInt32(txtMar.Text);
m3 = Convert.ToInt32(txtHindi.Text);
m4 = Convert.ToInt32(txtSci.Text);
m5 = Convert.ToInt32(txtMth.Text);
total = m1 + m2 + m3 + m4 + m5;
per = total * 100 / 500.0f;
if (m1 >= 35 && m2 >= 35 && m3 >= 35 && m4 >= 35 && m5
>= 35)
{
result = "PASS";
if (per >= 60)
div = "I";
else if (per >= 45)
div = "II";
else
div = "III";
}
else
{
result = "FAIL";
div = "NA";
}
lblTotal.Text = total.ToString();
lblPer.Text = per.ToString();
lblResult.Text = result;
lblDiv.Text = div;
}
• Double click on New button and code it as follow:
private void btnNew_Click(object sender, EventArgs e)
{
www.dotnetvideotutorial.com
txtRollNo.Text = "";
txtName.Text = "";
txtEng.Text = "";
txtMar.Text = "";
txtHindi.Text = "";
txtMth.Text = "";
txtSci.Text = "";
lblTotal.Text = "";
lblPer.Text = "";
lblResult.Text = "";
lblDiv.Text = "";
txtRollNo.Focus();
}
• Exit button:
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();
}

More Related Content

PDF
Windows Forms For Beginners Part - 3
PDF
Java conditional statements
PPTX
Basic controls of Visual Basic 6.0
PPTX
Windowforms controls c#
PDF
itft-Decision making and branching in java
PPT
Visual Basic menu
PPT
friend function(c++)
PPT
Visual basic
Windows Forms For Beginners Part - 3
Java conditional statements
Basic controls of Visual Basic 6.0
Windowforms controls c#
itft-Decision making and branching in java
Visual Basic menu
friend function(c++)
Visual basic

What's hot (20)

PPTX
Sdi & mdi
PPTX
C++ decision making
PPTX
Java swing
PDF
Lesson 02 python keywords and identifiers
PDF
Operator overloading
PPTX
PPTX
[OOP - Lec 18] Static Data Member
PPT
JavaScript Control Statements I
PPSX
Type conversion
PPTX
Java if else condition - powerpoint persentation
PDF
JavaScript - Chapter 12 - Document Object Model
PPTX
Polymorphism
PPTX
C# classes objects
PPTX
Inheritance in c++
PPT
C# Basics
PPTX
Enumeration in c#
PPTX
PHP and MySQL.pptx
PPTX
Object Oriented Programming with C#
PPTX
Classes objects in java
PPTX
Control statements in java
Sdi & mdi
C++ decision making
Java swing
Lesson 02 python keywords and identifiers
Operator overloading
[OOP - Lec 18] Static Data Member
JavaScript Control Statements I
Type conversion
Java if else condition - powerpoint persentation
JavaScript - Chapter 12 - Document Object Model
Polymorphism
C# classes objects
Inheritance in c++
C# Basics
Enumeration in c#
PHP and MySQL.pptx
Object Oriented Programming with C#
Classes objects in java
Control statements in java
Ad

Viewers also liked (16)

PPT
c#.Net Windows application
PDF
Windows Forms For Beginners Part - 2
PDF
Windows Forms For Beginners Part - 4
PPT
Introduction To Dotnet
PPT
PDF
C++ Windows Forms L02 - Controls P1
PDF
Windows Forms For Beginners Part 5
PPT
12 gui concepts 1
PPT
Csphtp1 12
PPT
ASP.NET 09 - ADO.NET
PPTX
ADO.NET -database connection
PPT
PDF
Asp .net web form fundamentals
PDF
E Commerce -Security Threats and Challenges
PPTX
Security in E-commerce
c#.Net Windows application
Windows Forms For Beginners Part - 2
Windows Forms For Beginners Part - 4
Introduction To Dotnet
C++ Windows Forms L02 - Controls P1
Windows Forms For Beginners Part 5
12 gui concepts 1
Csphtp1 12
ASP.NET 09 - ADO.NET
ADO.NET -database connection
Asp .net web form fundamentals
E Commerce -Security Threats and Challenges
Security in E-commerce
Ad

Similar to Windows Forms For Beginners Part - 1 (20)

PDF
Visualbasic tutorial
PPTX
Spf chapter 03 WinForm
PPTX
SPF WinForm Programs
PPTX
COM 211 PRESENTATION.pptx
PPTX
Vb6.0 intro
DOCX
The visual studio start page is shown in the figure below
PPT
C# Tutorial MSM_Murach chapter-02-slides
DOCX
Cis 355 i lab 4 of 6
DOCX
Cis 355 ilab 4 of 6
DOCX
Visual C# 2010
PPTX
lesson-9-Building-Windows-Form-Application.pptx
PPTX
lesson-9-Building-Windows-Form-Application.pptx
PDF
Software engineering modeling lab lectures
PDF
Gui builder
PPTX
Chapter 2 — Program and Graphical User Interface Design
PPTX
LECTURE 12 WINDOWS FORMS PART 2.pptx
PDF
Creating Windows-based Applications Part-I
PPTX
Vs c# lecture1
PPT
C# Tutorial MSM_Murach chapter-10-slides
PPT
4.7.14&17.7.14&23.6.15&10.9.15
Visualbasic tutorial
Spf chapter 03 WinForm
SPF WinForm Programs
COM 211 PRESENTATION.pptx
Vb6.0 intro
The visual studio start page is shown in the figure below
C# Tutorial MSM_Murach chapter-02-slides
Cis 355 i lab 4 of 6
Cis 355 ilab 4 of 6
Visual C# 2010
lesson-9-Building-Windows-Form-Application.pptx
lesson-9-Building-Windows-Form-Application.pptx
Software engineering modeling lab lectures
Gui builder
Chapter 2 — Program and Graphical User Interface Design
LECTURE 12 WINDOWS FORMS PART 2.pptx
Creating Windows-based Applications Part-I
Vs c# lecture1
C# Tutorial MSM_Murach chapter-10-slides
4.7.14&17.7.14&23.6.15&10.9.15

More from Bhushan Mulmule (12)

PDF
Implementing auto complete using JQuery
PDF
NInject - DI Container
PDF
Dependency injection for beginners
PPTX
Understanding Interfaces
PPTX
Polymorphism
PPTX
Inheritance
PPTX
Classes and objects
PPTX
PPTX
Arrays, Structures And Enums
PPTX
Flow Control (C#)
PPTX
Getting started with C# Programming
PPTX
Overview of .Net Framework 4.5
Implementing auto complete using JQuery
NInject - DI Container
Dependency injection for beginners
Understanding Interfaces
Polymorphism
Inheritance
Classes and objects
Arrays, Structures And Enums
Flow Control (C#)
Getting started with C# Programming
Overview of .Net Framework 4.5

Recently uploaded (20)

PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Encapsulation theory and applications.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Digital-Transformation-Roadmap-for-Companies.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
MIND Revenue Release Quarter 2 2025 Press Release
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Encapsulation_ Review paper, used for researhc scholars
Agricultural_Statistics_at_a_Glance_2022_0.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Big Data Technologies - Introduction.pptx
Encapsulation theory and applications.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Programs and apps: productivity, graphics, security and other tools
Advanced methodologies resolving dimensionality complications for autism neur...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton

Windows Forms For Beginners Part - 1

  • 1. Demo Projects • Simple Calculator • Student Progress Report What will you learn? • Designing simple user • Changing properties of controls • Writing event handler for button • Using following controls: o Labels o Textboxes o Buttons o Group-box Windows Forms for Beginners Student Progress Report ser interface Changing properties of controls Writing event handler for button’s click event controls: Bhushan Mulmule bhushan.mulmule@gmail.com www.dotnetvideotutorial.com Windows Forms for Beginners Part 1 Bhushan Mulmule bhushan.mulmule@gmail.com www.dotnetvideotutorial.com Windows Forms for Beginners
  • 2. Project 1: Basic Calculator • Create New Windows Form Application • Step 1: Design User Interface • Step 2: Change Properties of labels, textboxes and buttons • Step 3: Write Code for buttons Step 1: Design UI as follow: Labels Arrange No1, No2 and Result labels to align right walls Textboxes User should not able to type in result textbox. In next example to show output we will use labels Buttons
  • 3. www.dotnetvideotutorial.com Step 2: Set properties of controls as follow: Control Name Text Readonly Form frmBasicCalcii Basic Calculator Labels No need to change Names of labels at left hand side Basic Calculator Number 1: Number 2: Result: TextBoxes txtNo1 txtNo2 txtResult True Buttons btnPlus + btnMinus - btnMul * btnDiv / btnReset Reset btnExit Exit Step 3: Add event handlers for buttons 1. Double click on Plus button and code it as follow: private void btnPlus_Click(object sender, EventArgs e) { int no1, no2, result; no1 = Convert.ToInt32(txtNo1.Text); no2 = Convert.ToInt32(txtNo2.Text); result = no1 + no2; txtResult.Text = result.ToString(); } Note: Write similar code for minus, multiplication and division.
  • 4. www.dotnetvideotutorial.com 2. Double click Reset button and write code as follow: private void btnClear_Click(object sender, EventArgs e) { //txtNo1.Text = ""; txtNo1.Clear(); txtNo2.Clear(); txtResult.Clear(); txtNo1.Focus(); } 3. Double click Exit button and write code as follow: private void btnExit_Click(object sender, EventArgs e) { Application.Exit(); } 4. Application is ready execute and test. Project 2: Student Progress Report Step 1: Design UI And Change Properties as shown in callouts (Please use common sense☺☺☺☺) • Change Title Label Font size property to make it large • No need to change Name property of labels at left-hand side as not used in code • Change only Text property of labels as shown in image • Change names for all textboxes as specified in callouts respectively • Change names for Right hand side output labels for Total, Percentage, Division and Total. • Do not change names of left hand side total, percentage, division and total labels • To change looks of right hand side output labels change AutoSize: False, BackColor: White, BorderStyle: FixedSingle, Text: Blank • Change only Text property of Group-box.
  • 5. 2 Textboxes Name: txtRollNo, txtName 5 TextBoxes: Name: txtEng, txtMar, txtHindi, txtMaths, txtScience 3 Buttons: Name: btnOK, btnNew, btnExit Text: OK, New, Exit 2 Groupbox: Text: Scores, Result 11 Labels: Text: RollNo, Name, English, Marathi, Hindi, Math, Science, Total, Percentage, Division, Result 4 Labels: To Display output for Total, Percentage, Division and Result use Labels. To change looks of these four labels set following properties: AutoSize: False BackColor: White BorderStyle: FixedSingle Text: Blank Name: lblTotal, lblPer, lblDiv, lblResult
  • 6. www.dotnetvideotutorial.com Step 3: Add event handlers for buttons • Double click on OK and code it as follow: private void btnOK_Click(object sender, EventArgs e) { int m1, m2, m3, m4, m5, total; float per; string div="", result=""; m1 = Convert.ToInt32(txtEng.Text); m2 = Convert.ToInt32(txtMar.Text); m3 = Convert.ToInt32(txtHindi.Text); m4 = Convert.ToInt32(txtSci.Text); m5 = Convert.ToInt32(txtMth.Text); total = m1 + m2 + m3 + m4 + m5; per = total * 100 / 500.0f; if (m1 >= 35 && m2 >= 35 && m3 >= 35 && m4 >= 35 && m5 >= 35) { result = "PASS"; if (per >= 60) div = "I"; else if (per >= 45) div = "II"; else div = "III"; } else { result = "FAIL"; div = "NA"; } lblTotal.Text = total.ToString(); lblPer.Text = per.ToString(); lblResult.Text = result; lblDiv.Text = div; } • Double click on New button and code it as follow: private void btnNew_Click(object sender, EventArgs e) {
  • 7. www.dotnetvideotutorial.com txtRollNo.Text = ""; txtName.Text = ""; txtEng.Text = ""; txtMar.Text = ""; txtHindi.Text = ""; txtMth.Text = ""; txtSci.Text = ""; lblTotal.Text = ""; lblPer.Text = ""; lblResult.Text = ""; lblDiv.Text = ""; txtRollNo.Focus(); } • Exit button: private void btnExit_Click(object sender, EventArgs e) { Application.Exit(); }