1 / 21

CIS 338: Additional Controls

CIS 338: Additional Controls. Dr. Ralph D. Westfall April, 2011. Additional Interface Controls. TextBoxes, ListBoxes, Buttons, etc. are relatively simple parts of an interface VB.NET offers some more complex controls

andrew
Télécharger la présentation

CIS 338: Additional 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. CIS 338: Additional Controls Dr. Ralph D. Westfall April, 2011

  2. Additional Interface Controls • TextBoxes, ListBoxes, Buttons, etc. are relatively simple parts of an interface • VB.NET offers some more complex controls • MenuStrips make it possible to choose from multiple items, in an organized fashion • ToolStrips provide a graphic way (icons) for users to select actions

  3. Possible Menus in Applications • File menu if your program uses files for input and/or output • Edit menu – could use code to copy, cut and paste data in your TextBox controls • Windows – can have more than 1 with VB's Multiple Document Interface (MDI)

  4. Menu Issues • menu = choices for user • usually drop down and give more choices • make menu items similar to common ones, where possible • e.g., File, Edit, View, Tools, Window, Help • easier to learn and use • don't force users into this pattern if your choices don't fit well with common ones

  5. Setting Up a MenuStrip • drag/drop a MenuStrip control from Toolbox (Windows Forms) onto form • [click in "tray" below form to get focus] • type in caption in Type Here at form top • put & before keyboard shortcut letter • add subItem choices below where it says Type Here • add new items on right

  6. MenuStrip Shortcuts • can use Alt key for top level selections • [Alt] first letter is default top level shortcut • put & before any other letter for top level menu shortcutting (F&ormat) • underscore will show when press Alt key • setting up shortcut key (combinations) to select without using menu • drop down helps create combinations • best to follow common patterns • e.g., make copy be Ctrl-C (Ctrl+C)

  7. Multiple Level Issues • naming convention: mnu[top][2nd][3rd] • set in properties window • e.g., mnuFileNewWindow (IE browser) • triangle on right points to a submenu • … (3) dots after text means get more information (i.e., leads to a dialog box) • shortcut key shows on right if set = True

  8. Other Menu Item Capabilities • click dropdown triangle in Type Here • select Separator to create horizontal bar • has a name, just like other menu items • can also put a ComboBox or Textbox in menu to provide more choices for user or allow to type in a choice

  9. Invisible Menu Choices • can use for choices that show up with rest of menu items based on a user action e.g., • when another (not a child) form is visible • can create in Menu Editor like others • add a new top level choice to an existing menu • uncheck Visible for top level item

  10. Invisible Menu Choices - 2 • identify the event that will trigger the specified menu to become visible • create code for an event handler (e.g. double click a Button) • type code in the handler to show the menu • mnu[ ].Visible = True

  11. Code for Menu Items • click lowest level items (on form) • 2nd level items if 2 levels • usually wouldn't add an action until get to lowest level menu item • type in code to handle selection in window • example: MsgBox(" [ ] menu item OK")

  12. Multiple Level Menus • top level choices open second levels • 2nd opens 3rd, etc. • e.g., Tools>Macros>Macros IDE … (VB) • e.g., View>TextSize>Larger (IE) • VB.NET allows many levels ( >10 ) • how many menu levels are too much? • HCI (human computer interaction) experts: limit menu levels to not more than 3 (3 or less)

  13. VB ToolStrips • icons to control program • e.g., at top of screen in IE, Word, etc. • when user clicks, runs a command or changes a setting • e.g., sends to printer, changes font size

  14. Adding a ToolStrip • select ToolStrip control and drop on form • change Anchor property if desired • use dropdown to select items for it • adjust properties of added items, as desired

  15. Configuring ToolStrip Buttons • right click ToolStrip for options • Insert Standard Buttons provides buttons commonly used in Microsoft applications • set item values in Properties window • use a meaningful Name (btn[name]) • set ToolTipText property for text to show on a mouseover

  16. ToolStrip Buttons - 2 • set DisplayStyle to appropriate value • Image or Text • set Style to appropriate value (previous versions) • PushButton – runs code • ToggleButton – on/off • like B button for bold in Office • DropDownButton – drop down menu

  17. ToolStripMenuItem Properties • some ToolStripMenuItem properties • Checked – if True, shows check on item • Enabled – False means grayed out • Visible – can't see it if this property is False • ToolTipText – show explanatory information for the menu item when user mouses over it

  18. ToolStripMenuItem Properties • additional properties • Text – menu text • Name – object's name in code • ShortcutKeys – special key(s) that can run code instead of clicking menu • function keys (F1, etc.) • key combinations ( [Ctrl] [Z] ) • ShowShortcutKeys defaults to True

  19. Coding ToolStrip Buttons • click on ToolStrip button to get into Code window • add code as desired

  20. Coding ToolStrips • can add buttons in code 'general declarations Dim btnExit As New ToolStripButton() 'in a Sub btnExit.Text = "Exit" ToolStrip1.Buttons.Add(btnExit)

  21. ImageList Being Deprecated? • in Components section of Toolbox now • drag and drop it onto form • right click it, select Properties, click … (3 dots) by Images property • click Add button (get from directory): • Microsoft Visual Studio Graphicsthese images are in some folder in your Visual Studio installation (can someone find it?) • select pictures

More Related