Cis 338 additional controls
1 / 21

CIS 338: Additional Controls - PowerPoint PPT Presentation

  • Uploaded on

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

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'CIS 338: Additional Controls' - andrew

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Cis 338 additional controls l.jpg

CIS 338: Additional Controls

Dr. Ralph D. Westfall

April, 2011

Additional interface controls l.jpg
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

Possible menus in applications l.jpg
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)

Menu issues l.jpg
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

Setting up a menustrip l.jpg
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

Menustrip shortcuts l.jpg
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)

Multiple level issues l.jpg
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

Other menu item capabilities l.jpg
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

Invisible menu choices l.jpg
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

Invisible menu choices 2 l.jpg
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

Code for menu items l.jpg
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")

Multiple level menus l.jpg
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)

Vb toolstrips l.jpg
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

Adding a toolstrip l.jpg
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

Configuring toolstrip buttons l.jpg
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

Toolstrip buttons 2 l.jpg
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

Toolstripmenuitem properties l.jpg
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

Toolstripmenuitem properties18 l.jpg
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

Coding toolstrip buttons l.jpg
Coding ToolStrip Buttons

  • click on ToolStrip button to get into Code window

    • add code as desired

Coding toolstrips l.jpg
Coding ToolStrips

  • can add buttons in code

    'general declarations

    Dim btnExit As New ToolStripButton()

    'in a Sub

    btnExit.Text = "Exit"


Imagelist being deprecated l.jpg
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