![]() Private Sub bttnAddItem_Click(.) Handles bttnAddItem.Click Listing 5.12: Adding and RemovingMenu Items at Runtime Listing 5.12 shows the code behind the two buttons that add and remove menu items. ![]() To change this order and display the most recent command at the beginning of the menu, use the Insert method instead of the Add method to insert the new item. Each new command is appended at the end of the menu, and the commands are removed from the bottom of the menu first (the most recently added commands are removed first). The two buttons on the form add commands to and remove commands from the Run Time Menu. The main menu of the application’s form contains the Run Time Menu submenu, which is initially empty.įigure 5.18 – Adding and removing menu items at runtime The RunTimeMenu project (Figure 5.18) demonstrates how to add items to and remove items from a menu at runtime. When you first start the application, this list is empty, and as you open and close files, it starts to grow. Many applications maintain a list of the most recently opened files in the File menu. I conclude the discussion of menu design with a technique for building dynamic menus, which grow and shrink at runtime. It simply toggles the Visible property of certain menu commands and changes the command’s caption to Short Menu or Long Menu, depending on the menu’s current status. The subroutine in Listing 5.11 doesn’t do much. MnuAllCaps.Visible = True End If End Sub Code language: VB.NET ( vbnet ) Private Sub mnuMenuSize_Click(.) Handles mnuSize.Click The short version omits infrequently used commands and is easier to handle. The last command in the short menu should be Long Menu, and it should display the long version.įigure 5.17 shows a long and a short version of the same menu for the example the LongMenu Example. ![]() The last command in the long menu should be Short Menu, and when selected, it should display the short version. The first menu is the long one, and the second is the short one. ![]() If a menu contains many commands, and most of the time only a few of them are needed, you can create one menu with all the commands and another with the most common ones. Adding and removing menu commands at runtimeĪ common technique in menu design is to create long and short versions of a menu.Creating short and long versions of the same menu.This section explores two techniques for implementing dynamic menus: Dynamic menus change at runtime to display more or fewer commands, depending on the current status of the program. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |