Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleLet the user pick a new interface for all forms when they are activated
Keywordsuser interface, customize
CategoriesSoftware Engineering
 
Let the user select a style for all of the forms in the application. This example just makes some trivial changes. A real application might change the language used by the forms.

This example assumes it will take a while to change all the forms, so it defers the changes as long as possible. It only updates a form when it is next activated.

My book Advanced Visual Basic Techniques demonstrates another method for customizing user interfaces. When the user logs in, the program uses the user's privileges stored in a database to customize the interface for that user. For example, basic users might not be allowed to see all of the data of might be able to see but not modify.

 
' Select the new user interface.
Private Sub cboUIChoice_Click()
    ' Do nothing if we are just updating the
    ' ComboBox (see Form_Activate).
    If UpdatingCbo Then Exit Sub

    ' Record the setting for everyone else.
    SelectedInterface = cboUIChoice.ListIndex

    ' Update our interface.
    Form_Activate
End Sub

' Make sure we have the correct user interface.
Private Sub Form_Activate()
    ' If we are already using the right interface,
    ' do nothing.
    If CurrentInterface = SelectedInterface _
        Then Exit Sub

    ' Make the ComboBox's Click event do nothing.
    UpdatingCbo = True
    cboUIChoice.ListIndex = SelectedInterface
    UpdatingCbo = False

    ' **********************************
    ' * Set the correct interface here *
    ' **********************************
    ' Use the correct interface.
    lblInterface(CurrentInterface).Visible = False
    lblInterface(SelectedInterface).Visible = True
    ' *************************************
    ' * End setting the correct interface *
    ' *************************************

    ' Remember which interface we are using.
    CurrentInterface = SelectedInterface
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated