Mata kuliah : M0874 – Programming II Tahun : 2010 Graphical User Interface Concepts - Part 2 Session 09 Outline Materi •Menus •LinkLabels •ListBoxes and CheckedListBoxes •ComboBoxes •TreeViews •ListViews •Tab Control •MDI Windows Bina Nusantara University 3 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. Bina Nusantara University 4 Menus, submenus, and menu items Bina Nusantara University 5 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. Bina Nusantara University 6 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 Bina Nusantara University 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. 7 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. Bina Nusantara University 8 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. Bina Nusantara University 9 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. Bina Nusantara University 10 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. Bina Nusantara University 11 Bina Nusantara University 12 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. Bina Nusantara University 13 Bina Nusantara University 14 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. 15 Bina Nusantara University Bina Nusantara University 16 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. Bina Nusantara University 17 TreeView properties and an event Bina Nusantara University 18 TreeNode properties and methods Bina Nusantara University 19 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. Bina Nusantara University 20 Bina Nusantara University 21 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 ); Bina Nusantara University 22 TabControl properties and an event Bina Nusantara University 23 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. Bina Nusantara University 24 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 Bina Nusantara University windows, each has only one parent window. 25 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. Bina Nusantara University 26 Bina Nusantara University 27 References •http://books.google.co.id/books?id=euV7e2fRzsC&pg=PA472&lpg=PA472&dq=control+properties+and+l ayout+c%23&source=bl&ots=LCz4YdGcOB&sig=kFd6TiqM Wz2y3u8rAfaMDfmRVAg&hl=id&ei=s6ROS7rwNsqLkAXlxf2 cDQ&sa=X&oi=book_result&ct=result&resnum=6&ved=0CC EQ6AEwBQ#v=onepage&q=&f=false •http://www.youtube.com/watch?v=nWBQseysWhc &feature=related Bina Nusantara University 28