Lecture 10 Additional Controls and Objects - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Lecture 10 Additional Controls and Objects

Description:

UMDNJ - School of Health Related Professions. BINF5135. Clinical Systems Interface Design ... Multiple forms: A VB program can contain more than one form. ... – PowerPoint PPT presentation

Number of Views:38
Avg rating:3.0/5.0
Slides: 19
Provided by: hele69
Category:

less

Transcript and Presenter's Notes

Title: Lecture 10 Additional Controls and Objects


1
Lecture 10 Additional Controls and Objects

2
List Boxes and Combo Boxes
  • See Figure 11.1, p. 498
  • Combo boxes list box text box

3
List Box Control
  • List box will display a single column of strings,
    referred to as items.
  • The items appear initially can be specified
  • either at design time with the List property
  • Sorted property
  • When it is set to True, the items will
    automatically be displayed in alphabetical order.
  • The default value is False
  • or set with code in the Form_Load event
    procedure
  • code is used to access, add, or delete items from
    the list
  • The prefix for the name of a list box is lst.

4
Set Items with Code
  • lstBox.AddItem str Add str to the list box
    lstBox.
  • If Sorted property is True, str is added at the
    proper sorted position
  • Otherwise, at the end of list
  • lstBox.ListCount The number of items in the list
    box lstBox.
  • Each item in the lstBox is identified by an index
    number ranging from 0 through lstBox.ListCount-1
  • lstBox.NewIndex the index number of the item
    most recently added to lstBox by the AddItem
    method.
  • lstBox.ListIndex the index number of the item
    currently highlighted in lstBox
  • If no item is highlighted, the value of ListIndex
    is -1.

5
Set Items with Code (contd)
  • lstBox.List(n) the item of lstBox having index
    n.
  • The string array lstBox.List() holds the list of
    items stored in the list box.
  • E.g., Print lstBox.List(0) displays the first
    item of lstBox.
  • lstBox.List(lstBox.ListIndex) or List1.Text the
    item (string) currently highlighted in list box
    List1.
  • lstBox.RemoveItem n deletes the item of index n
    from lstBox.
  • lstBox.RemoveItem lstBox.ListIndex deletes the
    item currently highlighted in lstBox.
  • lstBox.Clear deletes every item of lstBox.

6
Examples
  • See Example 1 and 2, p. 499--502
  • Note The index associated with an item will
    change when a lesser item is added to or
    removed from the list.
  • lstBox.ItemData(n) m associates the number m
    with the item of index n
  • lstBox.ItemData(lstBox.NewIndex) m associates
    the number m with the item most recently added to
    the list box.
  • lstBox can be thought of as consisting of two
    arrays, lstBox() and lstBox.ItemData().

7
Combo Box Control
  • Combo box a text box with a help list attached.
  • Either typing in information into the box
  • or selecting the appropriate piece of information
    from a list.
  • Two most useful types of combo box (see fig.
    11.2)
  • style 0 the list drops down when the user clicks
    on the arrow, and then disappears after a
    selection is made.
  • Style 1 the list is always visible.
  • In either case, when an item from the list is
    highlighted, the item appears in the text box at
    the top and its value is assigned to the Text
    property of the combo box.

8
Combo Box Control
  • Combo boxes have essentially the same properties,
    events, and methods as list box.
  • All statements discussed for list boxes also hold
    for combo boxes.
  • The Style property of a combo box must be
    specified at design time.

9
Example
  • See EXAMPLE 3, p.503

10
File-related List Boxes
  • VB provides the appropriate lists for the three
    boxes.
  • Drive box
  • Directory box
  • File box
  • The selected items for three controls are
    identified by the Drive, Path, and FileName
    properties, respectively.

11
EXAMPLE
  • See EXAMPLE 4, p. 504

12
Homework
  • EXERCISES 11.1, 32 and 34.

13
Nine Elementary Controls
  • Frame control
  • Used to group related sets of controls for visual
    effect.
  • Important when working with groups of option
    button controls.
  • Check box control consists of a small square and
    a caption, presents the user with a yes/no
    choice. (see EXAMPLE 1)
  • Value property of a check box is 0 when the
    square is empty and is 1 otherwise.

14
Nine Elementary Controls (contd)
  • Option button control
  • Used to give the user a single choice from
    several options.
  • A group of several option buttons is attached to
    a frame or a picture box.
  • Value property of an option button tells if the
    button is on or off. (True or False)

15
Nine Elementary Controls (contd)
  • Horizontal and Vertical scroll bar controls
  • The main properties of a scroll bar control are
    Min, Max, Value, SmallChange, and LargeChange.
  • See EXAMPLE 5, p. 516
  • Timer control
  • Shape control
  • Line control
  • Image control

16
Homework
  • EXERCISES 11.2, 40, p.523

17
Five Additional Objects
  • The Menu control
  • Lab create Figure 11.17
  • Clipboard object used to copy or move text from
    one location to another
  • Clipboard.SetText str replaces any text
    currently in the clopboard with str.
  • str Clipboard.GetText() assign the text in the
    clopboard to the string variable str.
  • Clipboard.Clear deletes the contents of the
    clipboard

18
Five Additional Objects
  • Multiple forms A VB program can contain more
    than one form.
  • Additional forms are created from the Project
    menu with AddForm
  • Forms are hidden or activated with the statement
    Form1.Hide or Form2.Show
  • Two or more forms can be visible at the same time
  • formName.Show 1 Form formName is said to be
    modal. The user will not be allowed to shift the
    focus to any other form until formName is hidden.
Write a Comment
User Comments (0)
About PowerShow.com