0% found this document useful (0 votes)
30 views63 pages

Numeric LinkedLabel Tab Menu Controls

Uploaded by

Marah qasem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views63 pages

Numeric LinkedLabel Tab Menu Controls

Uploaded by

Marah qasem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 63

Chapter 14 and 15 of Visual C# How to Program, 6/e

©1992-2017 by Pearson Education, Inc. All Rights Reserved.


 Restricting a user’s input choices to a specific range of numeric
values can be done with a NumericUpDown control.
 A user can type numeric values into this control or click up and
down arrows.
 Figure 14.35 describes common NumericUpDown properties and an
event.

©1992-2017 by Pearson Education, Inc. All Rights Reserved.


©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
 Figure 14.36 demonstrates a NumericUpDown control in a GUI app
that calculates interest rate.
 For the NumericUpDown control, we set the Minimum to 1 and the
Maximum to 10.
 We set the NumericUpDown’s ReadOnly property to true to indicate
that the user cannot type a number into the control.

©1992-2017 by Pearson Education, Inc. All Rights Reserved.


©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
 The LinkLabel control displays links to other resources, such as
files or web pages (Fig. 15.12).

©1992-2017 by Pearson Education, Inc. All Rights Reserved.


©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
 When clicked, the LinkLabel generates a LinkClicked event
(Fig. 15.13).
 Class LinkLabel is derived from class Label and therefore inherits
all of class Label’s functionality.

©1992-2017 by Pearson Education, Inc. All Rights Reserved.


©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
 Class LinkLabelTestForm (Fig. 15.14) uses three LinkLabels.
 Method Start of class Process allows you to execute other
programs, or load documents or web sites from an app.

©1992-2017 by Pearson Education, Inc. All Rights Reserved.


©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
 The TabControl creates tabbed windows, such as those in Visual
Studio (Fig. 15.32)

©1992-2017 by Pearson Education, Inc. All Rights Reserved.


©1992-2017 by Pearson Education, Inc. All Rights Reserved.
 TabControls contain TabPage objects, which are similar to Panels.
 First add controls to the TabPage objects, then add the TabPages to
the TabControl.
▪ myTabPage.Controls.Add(myControl);
▪ myTabControl.TabPages.Add(myTabPage);
 We can use method AddRange to add an array of TabPages or
controls to a TabControl or TabPage.

©1992-2017 by Pearson Education, Inc. All Rights Reserved.


©1992-2017 by Pearson Education, Inc. All Rights Reserved.
 Add TabControls visually by dragging and dropping them onto a
Form in Design mode.
 To add TabPages in Design mode, click the top of the TabControl,
open its smart tasks menu and select Add Tab (Fig. 15.34).
 To select a TabPage, click the control area underneath the tabs.
 Common properties and a common event of TabControls are
described in Fig. 15.35.

©1992-2017 by Pearson Education, Inc. All Rights Reserved.


©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
 Class UsingTabsForm (Fig. 15.36) uses a TabControl to display
various options relating to the text on a label (Color, Size and
Message).

©1992-2017 by Pearson Education, Inc. All Rights Reserved.


©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
 Menus provide groups of related commands for Windows Forms
apps (Fig. 15.1).
 Menus organize commands without “cluttering” the GUI.

©1992-2017 by Pearson Education, Inc. All Rights Reserved.


©1992-2017 by Pearson Education, Inc. All Rights Reserved.
 To create a menu, open the Toolbox and drag a MenuStrip control
onto the Form.
 To add menu items to the menu, click the Type Here TextBox
(Fig. 15.2) and type the menu item’s name.

©1992-2017 by Pearson Education, Inc. All Rights Reserved.


©1992-2017 by Pearson Education, Inc. All Rights Reserved.
 After you press the Enter key, the menu item is added.
 More Type Here TextBoxes allow you to add more items (Fig. 15.3).

©1992-2017 by Pearson Education, Inc. All Rights Reserved.


©1992-2017 by Pearson Education, Inc. All Rights Reserved.
 Menus can have Alt key shortcuts which are accessed by pressing Alt
and the underlined letter.
 To make the File menu item have a key shortcut, type &File.
 The letter F is underlined to indicate that it’s a shortcut.

©1992-2017 by Pearson Education, Inc. All Rights Reserved.


 Menu items can have shortcut keys as well (Ctrl, Shift, Alt, F1, F2,
letter keys, and so on).
 To add other shortcut keys, set the ShortcutKeys property
(Fig. 15.4).

©1992-2017 by Pearson Education, Inc. All Rights Reserved.


©1992-2017 by Pearson Education, Inc. All Rights Reserved.
 You can remove a menu item by selecting it with the mouse and
pressing the Delete key.
 Menu items can be grouped by separator bars, which are inserted by
right clicking and selecting Insert > Separator or by typing “-” for
the text of a menu item.

©1992-2017 by Pearson Education, Inc. All Rights Reserved.


©1992-2017 by Pearson Education, Inc. All Rights Reserved.
 Visual Studio allows you to add TextBoxes and ComboBoxes as
menu items.
 Before you enter text for a menu item, you are provided with a drop-
down list.
▪ Clicking the down arrow allows you to select the type of item to add
(Fig. 15.5).

©1992-2017 by Pearson Education, Inc. All Rights Reserved.


©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
 Class MenuTestForm (Fig. 15.7) creates a simple menu on a Form.

©1992-2017 by Pearson Education, Inc. All Rights Reserved.


©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.
©1992-2017 by Pearson Education, Inc. All Rights Reserved.

You might also like