VB Logo

Tutorial: Menus and List Manipulation


Create a Visual Basic program to satisfy the description below.

Interface


Behaviour

This is a simple program conprising three drop down menus, three list boxes and a terminating button.

The menus all act upon the list boxes, changing the foreground/background colour, the font size and type and allowing insertion and deletion of entries. Any of these actions affect all three lists simultaneously.

The menu structures are given below.

Note: Clicking on any list item should cause the other two lists to highlight the corresponding words immediately.

Colours                      Fonts               Vocabulary
  Foreground>  Grey            Size>  10pt         Add
               Light Blue             12pt         Delete
               Light Green            15pt
               Light cyan             20pt
  Backgound>   Black                  25pt
               Blue            Type>  Roman
               Green                  Script
               Cyan                   Courier
               Red                    Modern
               Magenta
               Yellow

Hints

  1. If you do not know how to create a pull down menu please read - Pull Down and Popup Menus.

  2. Enter the data into the lists so that corresponding words have the same index position in each list. You can put all the AddItem statements in the FormLoad procedure or use your own Add function on the menubar to do it at run time. Feel free to vary the languages or vocabularies.

  3. The property ListIndex gives the position of the currently selected (highlighted) item in a list. The way to synchronise the lists is to assign the just selected ListIndex to the other lists, so in the Click event of lstFrench we would put:

      lstGerman.ListIndex = lstFrench.ListIndex
      lstEnglish.ListIndex = lstFrench.ListIndex
    

    Note: meaningful names are better than List1, List2, List3.

  4. To delete the currently highlighted words in the three lists, just use ListIndex to access them.

  5. The Add function needs to prompt the user for the three items of vocabulary and append these to the appropriate lists. There are various possibilities to investigate.



Tutorial 4 (List Boxes and Combo Boxes)
Menu
Tutorial 6 (Creating and using Arrays of Controls)