graphical user interface concepts - part 2 session 09 mata kuliah: m0874 – programming ii tahun:...

28

Upload: shona-garrett

Post on 13-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010
Page 2: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Graphical User Interface Concepts - Part 2

Session 09

Mata kuliah : M0874 – Programming IITahun : 2010

Page 3: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

3

Outline Materi

•Menus•LinkLabels•ListBoxes and CheckedListBoxes•ComboBoxes•TreeViews•ListViews•Tab Control•MDI Windows

Page 4: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

4

Menus

•Menus provide groups of related commands for Windows applications.•Menus are an integral part of GUIs, because they organize commands without “cluttering” the GUI.

Page 5: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

5

Menus, submenus, and menu items

Page 6: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

6

MenuStrip and ToolStripMenuItem properties and an event

MenuStrip and ToolStripMenuItem properties and an event

Description

MenuStrip Properties

MenuItems Contains the top-level menu items for this MenuStrip.

HasChildren Indicates whether MenuStrip has any child controls (menu items).

RIghtToLeft Causes text to display from right to left. This is useful for languages that are read from right to left.

ToolStripMenuItem Properties

Checked Indicates whether a menu item is checked. The default value is false, meaning that the menu item is unchecked.

CheckOnClick Indicates that a menu item should appear checked or unchecked as it is clicked.

Index Specifies an item’s position in its parent menu. A value of 0 places the MenuItem at the beginning of the Menu.

MenuItems Lists the submenu items for a particular menu item.

Page 7: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

7

MenuStrip and ToolStripMenuItem properties and an event

MenuStrip and ToolStripMenuItem properties and an event

Description

ShortcutKeyDisplayString Specifies text that should appear beside a menu item for a shortcut key. If left blank, the key names are displayed. Otherwise, the text in this property is displayed for the shortcut key.

ShortcutKeys Specifies the shortcut key for the menu item.

ShowShortCutKeys Indicates whether a shortcut key is shown beside menu item text. The default is true, which displays the shortcut key.

Text Specifies the menu item’s text. To create an Alt access shortcut, precede a character with &.

Common ToolStripMenuITem Event

Click Generated when an item is clicked or a shortcut key is used. This is the defaulte event when the menu is double-clicked in the designer.

Page 8: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

8

LinkLabels

•The LinkLabel control displays links to other resources, such as files or web pages.•A LinkLabel appears as underlined text (colored blue by default).•When the mouse moves over the link, the pointer changes to a hand; this is similar to the behavior of a hyperlink in a web page.•The link can change color to indicate whether it is not yet visited, previously visited or active.

Page 9: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

9

LinkLabels

•A LinkLabel is the preferred control for indicating that the user can click a link to jump to a resource such as a web page, though other controls can perform similar tasks.

Page 10: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

10

LinkLabel properties and an event

Description

Common Properties

ActiveLinkColor Specifies the color of the active link when clicked.

LinkArea Specifies which portion of text in the LinkLabel is part of the link.

LinkBehavior Specifies the link’s behavior, such as how the link appears when the mouse is placed over it.

LinkColor Specifies the original color of all links before they have been visited. The default color is set by the system, and is usually blue.

LinkVisited If true, the link appears as though it has been visited.

Text Specifies the control’s text.

UseMnemonic If true, the & character in the Text property acts as a shortcut.

VisitedLinkColor Specifies the color of visited links. The default color is set by the system, and is usually purple.

Common Event (Event arguments LinkLabelLinkClickedEventArgs)

LinkClicked Generated when the link is clicked. This is the default event when the control is double clicked in Design mode.

Page 11: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

11

ListBoxes

•The ListBox control allows the user to view and select from multiple items in a list.•ListBoxes are static GUI entities, which means that users cannot directly edit the list of items.•The user can be provided with TextBoxes and Buttons with which to specify items to be added to the list, but the actual additions must be performed in code.

Page 12: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

12

Page 13: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

13

CheckedListBoxes

•The CheckedListBox control derives from ListBox and displays a CheckBox with each item.•Items can be added via methods Add and AddRange or through the String Collection Editor.•CheckedListBoxes allow multiple items to be checked, but item selection is more restrictive.

Page 14: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

14

Page 15: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

15

ComboBoxes

•The CombBox control combines TextBox features with a drop-down list-a GUI component that contains a list from which a value can be selected.•A ComboBox usually appears as a TextBox with a down arrow to its right.•By default, the user can enter text into the TextBox or click the down narrow to display a list of predefined items.•If a user chooses an element from this list, that element is displayed in the TextBox.

Page 16: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

16

Page 17: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

17

TreeViews

•The TreeView control displays nodes hierarchically in a tree.•Nodes are objects thTht contain values and can refer to other nodes.•A parent node contains child nodes, and the child nodes can be parents to other nodes.•Two child nodes that have the same parent node are considered sibling nodes.•A tree is a collection of nodes, usually organized in a hierarchical manner.•The first parent node of a tree is the root node.

Page 18: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

18

TreeView properties and an event

Page 19: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

19

TreeNode properties and methods

Page 20: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

20

ListViews

•The ListView control is similar to a ListBox in that both display lists from which the user can select one or more items.•ListView is more versatile and can display items in different formats.•For example, a ListView can display icons next to the list items (controlled by its ImageList property) and show the details of items in columns.

Page 21: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

21

Page 22: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

22

Tab Control•TabControl creates tabbed windows, such as those we have seen in Visual Studio.•This allows you to specify more information in the same space on a Form and enables you to group displayed data logically.•TabControls contain TabPage objects, which are similar to Panels and GroupBoxes in that TabPages also can contain controls.•First ada controls to the TabPage objects, then add the TabPages to the TabControl. Only one TabPage is dispayed at a time.•To add objects to the TabPage and the TabControl, write

myTabPage.Controls.Add ( myControl );myTabControl.TabPages.Add ( myTabPage );

Page 23: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

23

TabControl properties and an event

Page 24: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

24

MDI Windows

•Previously, we have built only single document interface (SDI) applications.•SDI applications usually have limited abilties-Paint and Notepad for example have limited image-and text-editing features.•To edit multiple documents, the user must execute another instance of the SDI application.

Page 25: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

25

MDI Windows

•Many complex applications are multiple document interface (MDI) programs, which allow users to edit multiple documents at once.•MDI programs also tend to be more complex-Paint Shop Pro and Photoshop have a greater number of image-editing features than does Paint.•An MDI program’s main window is called the parent window, and each window inside the application is referred to as a child window.•Although an MDI application can have many child windows, each has only one parent window.

Page 26: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

26

MDI Windows

•In general, to add a child Form to a parent, write

ChildFormClass childForm = New ChildFormClass();childForm.MdiParent = parentForm;childForm.Show();

•Child windows can be minimized, maximized and closed independently of the parent window.

Page 27: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

27

Page 28: Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010

Bina Nusantara University

28

References

•http://books.google.co.id/books?id=euV7e2f-RzsC&pg=PA472&lpg=PA472&dq=control+properties+and+layout+c%23&source=bl&ots=LCz4YdGcOB&sig=kFd6TiqMWz2y3u8rAfaMDfmRVAg&hl=id&ei=s6ROS7rwNsqLkAXlxf2cDQ&sa=X&oi=book_result&ct=result&resnum=6&ved=0CCEQ6AEwBQ#v=onepage&q=&f=false

•http://www.youtube.com/watch?v=nWBQseysWhc&feature=related