CH3 2
CH3 2
CH3 2
1
Adding controls to a Blank window form
Compiled By Abrham Y. 3
Cont…
Compiled By Abrham Y. 4
Cont…
Compiled By Abrham Y. 5
Button Control
Compiled By Abrham Y. 6
Button Control
• The button control represents a standard
windows button .
• It is generally used to generate a click
events by providing a handler for the click
event
Compiled By Abrham Y. 7
Adding Button controls to a
window form
Compiled By Abrham Y. 8
Properties of the button control
Property Description
Text Get or set the text associated with
control
Name This is the actual name of the button
BackColor Gets or sets the background color of the
button
Image Gets or sets the image that is displayed
on a button control.
TextAlign Gets or sets the alignment of the text on
the button control
………………………. ………………………….
……………………….. …………………………….
etc etc
Compiled By Abrham Y. 9
Event associated with Button
Event
• An event is an member of a class, used to perform
required action
• Event is similar to function but pointed by a
delegate or function pointer
• Every event will have particular period of time
that is to be called as event raising/firing
• Delegate are completely backbone for the event
Compiled By Abrham Y. 10
Event associated with Button
Event Description
Click Occurs when the controls is clicked
Double click Occurs when the user double-click the button
controls
GotFocus Occurs when the controls receives focus
TextCange Occurs when the text property value changed
Tapindexcange Occurs when the tabindex property value change
Validate Occurs when the control is finished validating
Compiled By Abrham Y. 11
Example
Step1
12
Compiled By Abrham Y.
Cont..
Step 2: write code
1. Change the name of the button as btn1,
btn2, btn3
2. Set the text btn1 as Show Moto, btn2 as
Show Logo and btn3 as Exit
3. Handle the click event
1. If Show Moto click change the text to click
2. If show logo click change the text Show Logo
3. If exit click change the text to tanks
13
Compiled By Abrham Y.
Label Control
Compiled By Abrham Y. 14
Label Control
Compiled By Abrham Y. 15
Adding Label controls to a
window form
Compiled By Abrham Y. 16
Reading Assignment
Compiled By Abrham Y. 17
TextBox Control
Compiled By Abrham Y. 18
TextBox Control
Compiled By Abrham Y. 19
Adding TextBox controls to a
window form
Compiled By Abrham Y. 20
Properties of the TextBox control
Property Description
Text Gets or sets the current text in the TextBox.
Name Gets or sets the current name of TextBox.
MultiLine True: data in the textbox appears in more than one
True lines
False(Default) False: data in the textbox appears in one lines
PasswordChar Gets or sets the character used to mask characters of a
password in a single-line TextBox control.
ReadOnly True: data in the textbox is editable
True False: data in the textbox is not editable
False (Default)
ScrollBars None: no scroll bar appears to the control
None (Default) Horizontal : horizontal scroll bar appears to the control
Horizontal Vertical: vertical scroll bar appears to the control
Vertical Both : both scroll bar appears to the control 21
Both
Event associated with TextBox
Event Description
Click Occurs when the text box is clicked
KeyDown Occurs when a key is pressed while the control has focus
KeyPress Occurs when a key is pressed while the control has focus
KeyUP Occurs when a key is released while the control has focus
MouseDown Occurs when the mouse pointer is over the control and a
mouse button pressed
MuseUp Occurs when the mouse pointer is over the control and a
mouse button released
Etc Etc 22
Compiled By Abrham Y.
Example 1
Step1:Design and create the user interface
Compiled By Abrham Y. 23
Cont…
Step2: write code
1. The application should respond to this
click event add, subtract , multiply and
divide
Compiled By Abrham Y. 24
Example 2
Step1:Design and create the user interface
Compiled By Abrham Y. 25
Cont…
Step2: write code
1. The application should respond to this
click event Login and Exit
2. Add two button to login form change the
text to show password and hide password ,
The application should respond to click
show password and hide password
Compiled By Abrham Y. 26
Example 3
Step1:Design and create the user interface
Compiled By Abrham Y. 27
Compiled By Abrham Y. 28
Example 4
Compiled By Abrham Y. 29
Cont…
Step2: write code
1. The application should respond to compute
click event by calculating and filling the
deduction ,this OT payment as well as the
Net Payment in the respective textBoxs
Compiled By Abrham Y. 30
Example 5
Step1:Design and create the user interface
Compiled By Abrham Y. 31
Cont…
Step2: write code
1. Cmd Left click :move the form to the left by 1000 twips
2. Cmd Up click :move the form to the top by 1000 twips
3. Cmd Wider click :make the width of the form 1000 twips
grater than its current value
4. Cmd Longer click :make the length of the form 1000
twips grater than its current value
5. Cmd Red click: make the background color of the form
Red
6. Cmd Yellow click: make the fourground color of the
form Yellow
Compiled By Abrham Y. 32
Example 6
Step1:Design and create the user interface
33
Compiled By Abrham Y.
Cont…
Step2: write code
1. Cmd Larger click :change font size C#.net to 40
2. Cmd smaller click :change font size C#.net to 7
Compiled By Abrham Y. 34
Example 7
Step1:Design and create the user interface
35
Compiled By Abrham Y.
Cont…
Step2: write code
1. The application should respond to this
click event Reset
Compiled By Abrham Y. 36