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 immediately
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 be quick to change all the forms, so it makes the changes immediately.

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 SetUI).
    If UpdatingCbo Then Exit Sub

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

' Make sure we have the correct user interface.
Public Sub SetUI()
    ' 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