Lab 4 Slides - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

Lab 4 Slides

Description:

When we double-click it, a second event procedure is created ... Each time just get the sender.text to check the letter chosen !!!! 4. Reloading the Form ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 14
Provided by: reha6
Category:
Tags: lab | slides

less

Transcript and Presenter's Notes

Title: Lab 4 Slides


1
Lab 4 Slides
2
In this lab
  • CheckBoxes and RadioButtons
  • Enabled and Visible Properties
  • Multiple Events by Single Handler
  • Reloading the Form

3
1. CheckBoxes and RadioButtons
  • CheckBoxes
  • Any number can be checked at a time
  • RadioButtons
  • Usually organized in groups and only one checked
    at a time

4
CheckBox Properties and Events
5
CheckBox- Example
  • Private Sub CheckBox1_CheckedChanged(ByVal
    sender As _ System.Object, ByVal e As
    System.EventArgs) Handles _ CheckBox1.CheckedChang
    ed
  • If CheckBox1.Checked TrueThen
  • MsgBox(Checked)
  • Else
  • MsgBox(Not Checked)
  • End If
  • End Sub

6
RadioButton Properties and Events
7
2. Enabled and Visible Properties
8
3. Multiple Events by Single Handler
  • The Handles keyword makes a proper connection
    between the object (Button) and the event
    procedure.

Private Sub Button1_Click(   ByVal sender As _
system.object,   ByVal e As System.EventArgs) _
Handles Button1.Click . End Sub
B1
Event (means, when Button1 is clicked , execute
this procedure)
Name Button1 Text B1
9
3. Multiple Events by Single Handler
  • A specific event procedure can handle more than
    one event.
  • For example, adding a second button to the form,
    (automatically named Button2 ). When we
    double-click it, a second event procedure is
    created
  • Private Sub Button2_Click( ByVal sender As
    System.Object, _ ByVal e As System.EventArgs)
    Handles Button2.Click
  • Instead, the first Click procedure can be
    modified to handle both buttons' Click events
  • Private Sub Button1_Click( ByVal sender As
    System.Object, _ ByVal e As System.EventArgs)
    Handles _
  • Button1.Click, Button2.Click
  • For most events, the object that raises the event
    is passed in as the "sender" to the event
    procedure. The sender parameter is typed as an
    object.

10
3. Multiple Events by Single Handler
Code view
Design view
Private Sub LotsOfButtons(ByVal sender As _
System.Object,ByVal e As System.EventArgs)
_  Handles Button1.Click, Button2.Click,
Button3.Click, Button4.Click   label1.text
sender.text is clicked End Sub
b1
b2
b3
b4
Name label1
11
3. Multiple Events by Single Handler
code view
Design view
Private Sub LotsOfButtons(ByVal sender As _
System.Object,ByVal e As System.EventArgs)
_  Handles Button1.Click, Button2.Click,
Button3.Click, Button4.Click   label1.text
sender.text is clicked End Sub
b1
b2
b3 is clicked
b3
b4
Name label1
The sender argument provides information about
the object that raises the event
12
Why do you need to know this ?
  • In sheet 3, you can handle clicking all the 26
    letters by single event handler.
  • Each time just get the sender.text to check the
    letter chosen !!!!

13
4. Reloading the Form
  • Google it ?
Write a Comment
User Comments (0)
About PowerShow.com