1 / 62

Some Interesting Controls

Some Interesting Controls. Some Interesting Controls. ListBox es and CheckedListBox es. ListBox View and select from multiple items Scroll bar appears if necessary CheckedListBox Items have checkbox Select multiple items at same time Scroll bar appears if necessary.

lyre
Télécharger la présentation

Some Interesting Controls

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Some Interesting Controls

  2. Some Interesting Controls

  3. ListBoxes and CheckedListBoxes • ListBox • View and select from multiple items • Scroll bar appears if necessary • CheckedListBox • Items have checkbox • Select multiple items at same time • Scroll bar appears if necessary

  4. ListBoxes and CheckedListBoxes

  5. ListBoxes ListBox properties, methods and events

  6. ListBoxes

  7. ListBoxes

  8. ListBoxes

  9. CheckedListBoxes CheckedListBox properties, methods and events.

  10. CheckedListBox

  11. ListBox

  12. ListBox Control Public Class ListBox Inherits ListControl • The ListBox control enables you to display a list of items to the user that the user can select by clicking. • A ListBox control can provide single or multiple selections using the SelectionMode property. • The ListBox also provides the MultiColumn property to enable the display of items in columns instead of a straight vertical list of items. This allows the control to display more visible items and prevents the need for the user to scroll to an item. • In addition to display and selection functionality, the ListBox also provides features that enable you to efficiently add items to the ListBox and to find text within the items of the list.

  13. ListBox Control (continued) Public Class ListBox Inherits ListControl • The BeginUpdate and EndUpdate methods enable you to add a large number of items to the ListBox without the control being repainted each time an item is added to the list. • The FindString and FindStringExact methods enable you to search for an item in the list that contains a specific search string. • The Items, SelectedItems, and SelectedIndices properties provide access to the three collections that are used by the ListBox.

  14. CheckedListBox Control

  15. CheckedListBox Control Public Class CheckedListBox Inherits ListBox • This control presents a list of items that the user can navigate by using the keyboard or the scrollbar on the right side of the control. The user can place a check mark by one or more items and the checked items can be navigated with the CheckedListBox.CheckedItemCollection and CheckedListBox.CheckedIndexCollection. • To add objects to the list at run time, assign an array of object references with the AddRange method. The list then displays the default string value for each object. You can add individual items to the list with the Add method. • The CheckedListBox object supports three states through the CheckState enumeration: Checked, Indeterminate, and Unchecked. You must set the state of Indeterminate in the code because the user interface for a CheckedListBox does not provide a mechanism to do so. • If UseTabStops is true, the CheckedListBox will recognize and expand tab characters in an item's text, creating columns. However, the tab stops are present and cannot be changed.

  16. The CheckedListBox class supports the following three indexed collections • All items contained in the CheckedListBox control. • CheckedListBox.ObjectCollection • Checked items (including items in an indeterminate state), which is a subset of the items contained in the CheckedListBox control. • CheckedListBox.CheckedItemCollection • Checked indexes, which is a subset of the indexes into the items collection. These indexes specify items in a checked or indeterminate state. • CheckedListBox.CheckedIndexCollection

  17. Tab Control • TabControl • Creates tabbed windows • Saves space using TabPage objects • TabPage objects • Similar to Panels and GroupBoxes • Can contain controls

  18. Tab Control

  19. Tab Control

  20. Tab Control

  21. Tab Control TabControl properties and events.

  22. Tab Control

  23. TabControl

  24. TabControl Public Class TabControl Inherits Control • A TabControl contains tab pages, which are represented by TabPage objects that you add through the Controls property. • Note   The following events are not raised for the TabControl class unless there is at least one TabPage in the TabControl.TabPages collection: Control.Click, Control.DoubleClick, Control.MouseDown, Control.MouseUp, Control.MouseHover, Control.MouseEnter, Control.MouseLeave and Control.MouseMove. • If there is at least one TabPage in the collection, and the user interacts with the tab control’s header (where the TabPage names appear), the TabControl raises the appropriate event. However, if the user interaction is within the ClientRectangle of the tab page, the TabPage raises the appropriate event.

  25. TabPage Control

  26. TabPage Control Public Class TabPage Inherits Panel • Represents a single tab page in a TabControl. • For more information about how this control responds to the Focus and Select methods, see the following Control members: CanFocus, CanSelect, Focused, ContainsFocus, Focus, Select.

  27. Menus • Menu • Groups related commands • Organize without “cluttering” GUI • Menu items • Commands or options in menu • Sub-menu • Menu within a menu • Hot keys • Alt key shortcuts • Press Alt + underlined letter in desired menu item

  28. Menus

  29. Menus

  30. Menus

  31. Menus MainMenu and MenuItem properties and events.

  32. MainMenu Class

  33. MainMenu Class Public Class MainMenu Inherits Menu • Represents the menu structure of a form. • The MainMenu control represents the container for the menu structure of a form. • A menu is composed of MenuItem objects that represent the individual menu commands in the menu structure. • Each MenuItem can be a command for your application or a parent menu for other submenu items. • To bind the MainMenu to the Form that will display it, assign the MainMenu to the Menu property of the Form.

  34. MainMenu Class (continued) • You can create different MainMenu objects to represent different menu strutures for your form. • If you want to reuse the menu structure contained in a specific MainMenu, you can use its CloneMenu method to create a copy. Once you have a copy of the menu structure, you can make the appropriate modifications for your new menu structure.

  35. MenuItem Control

  36. MenuItem Control Public Class MenuItem Inherits Menu • Represents an individual item that is displayed within a MainMenu or ContextMenu. • In order for a MenuItem to be displayed, you must add it to a MainMenu or ContextMenu. To create submenus, you can add MenuItem objects to the MenuItems property of the parent MenuItem. • The MenuItem class provides properties that enable you to configure the appearance and functionality of a menu item. • To display a check mark next to a menu item, use the Checked property. You can use this feature to identify a menu item that is selected in a list of mutually exclusive menu items. For example, if you have a set of menu items for setting the color of text in a TextBox control, you can use the Checked property to identify which color is currently selected. • The Shortcut property can be used to define a keyboard combination that can be pressed to select the menu item.

  37. MenuItem Control (Continued) • For MenuItem objects displayed in a Multiple Document Interface (MDI) application, you can use the MergeMenu method to merge the menus of an MDI parent for with that of its child forms to create a consolidated menu structure. • Because a MenuItem cannot be reused in multiple locations at the same time, such as in a MainMenu and a ContextMenu, you can use the CloneMenu method to create a copy of a MenuItem for use in another location. • The Popup event enables you to perform tasks before a menu is displayed. For example, you can create an event handler for this event to display or hide menu items based on the state of your code. • The Select event enables you to perform tasks such as providing detailed help for your application's menu items when the user places the mouse cursor over a menu item.

  38. TreeView • TreeView Control • Displays nodes hierarchically • Nodes • Objects that contain values • Parent node • Contains child nodes • Can be expanded or collapsed • Root node • First parent node of a tree • Sibling nodes • Have same parent node • Child nodes • Can have child nodes of their own

  39. TreeView

  40. TreeView TreeView properties and events.

  41. TreeView TreeNode properties and methods.

  42. TreeView

  43. TreeView

  44. TreeView

  45. TreeView Control

  46. TreeView Control Public Class TreeView Inherits Control • Displays a hierarchical collection of labeled items, each represented by a TreeNode. • The Nodes collection holds all the TreeNode objects that are assigned to the TreeView control. • The tree nodes in this collection are referred to as the root tree nodes. • Any tree node that is subsequently added to a root tree node is referred to as a child node. • Because each TreeNode can contain a collection of other TreeNode objects, you might find it difficult to determine your location in the tree structure when you iterate through the collection. • You can parse the TreeNode.FullPath string by using the PathSeparator string value to determine where a TreeNode label begins and ends.

  47. TreeView Control (continued) • You can display images next to the tree nodes by assigning an ImageList object to the ImageList property, and referencing the index value of an Image in the ImageList to assign that Image. • Set the ImageIndex property to the index value of the Image that you want to display when a tree node is not selected. • Likewise, set the SelectedImageIndex property to the index value of the Image that you want to display when a tree node is selected. • The images referenced by the ImageIndex and SelectedImageIndex property values are the default images displayed by all the tree nodes that are assigned to the Nodes collection. • Each tree node can override the default images by setting the TreeNode.ImageIndex and TreeNode.SelectedImageIndex properties.

  48. TreeView Control (continued) • Tree nodes can be expanded to display the next level of child tree nodes. • The user can expand the TreeNode by clicking the plus-sign (+) button, if one is displayed next to the TreeNode, or you can expand the TreeNode by calling the TreeNode.Expand method. • To expand all the child tree node levels in the Nodes collection, call the ExpandAll method. • You can collapse the child TreeNode level by calling the TreeNode.Collapse method, or the user can press the minus-sign (-) button, if one is displayed next to the TreeNode. • You can also call the TreeNode.Toggle method to alternate between the expanded and collapsed states.

  49. TreeView Control (continued) • Tree nodes can optionally display check boxes. • To display the check boxes, set the CheckBoxes property of the TreeView to true. • The Checked property is set to true for tree nodes that are in a checked state. • Note Setting the TreeNode.Checked property from within the BeforeCheck or AfterCheck event causes the event to be raised multiple times and can result in unexpected behavior. For example, you might set the Checked property in the event handler when you are recursively updating the child nodes, so the user does not have to expand and check each one individually.

  50. TreeView Control (continued) • To prevent the event from being raised multiple times, add logic to your event handler that only executes your recursive code if the Action property of the TreeViewEventArgs is not set to TreeViewAction.Unknown. For an example of how to do this, see the Example section of the AfterCheck or BeforeCheck events. • You can change the appearance of the TreeView control by setting some of its display and style properties. • Setting ShowPlusMinus to true displays a plus-sign or minus-sign button next to each TreeNode object that can be expanded or collapsed, respectively. • Setting the ShowRootLines property to true causes the TreeView to display lines that join all the root tree nodes together. • You can display lines that connect child tree nodes to their root node by setting the ShowLines property to true.

More Related