Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual Basic
 How to: Emulate a Visual Basic 6.0 ...
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
Visual Basic Concepts 
How to: Emulate a Visual Basic 6.0 Tri-state Control in an Upgraded Application 

In Visual Basic 6.0, the Picture, DownPicture, and DisabledPicture properties are used to display different pictures based on the state of a CheckBox, CommandButton, or OptionButton control. For example, when a CheckBox control is checked, the DownPicture image is displayed; if the control is disabled, the DisabledPicture image is displayed.

In Visual Basic 2005 you can achieve the same effect using an ImageList control as outlined in the following example.

NoteNote

First, check your Visual Basic 6.0 application. If the DownPicture and DisabledPicture properties are not set at design time or run time, the behavior should be the same in Visual Basic 2005.

NoteNote

The dialog boxes and menu commands you see might differ from those described in Help, depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

Adding an ImageList Control

Take the following steps to modify the upgraded application if the DownPicture or DisabledPicture properties are set.

To emulate a tri-state control

  1. Determine the file names and locations of the images that were assigned to the Picture, DownPicture, and DisabledPicture properties and, if necessary, copy these to your development computer.

  2. From the Toolbox, add an ImageList control to your form.

  3. In the Properties window, select the Images property.

  4. In the Image Collection editor, add three images to be used for the Picture, then the DownPicture, and then the DisabledPicture.

  5. If any of the properties were set at run time, remove the code. If any of the properties were set at design time, add the following code to the Load event for the form:

    Visual Basic
    ' Assign the first image (Picture) to the Image property.
    CheckBox1.Image = ImageList1.Images(0)
  6. To display the DownPicture image at run time, add the following code to the CheckedChanged event for the CheckBox control.

    Visual Basic
    If CheckBox1.Checked = True Then
      ' Assign the second image (DownPicture) to the Image property.
      CheckBox1.Image = ImageList1.Images(1)
    Else
      ' Assign the first image (Picture) to the Image property.
      CheckBox1.Image = ImageList1.Images(0)
    End If
  7. To display the DisabledPicture image at run time, add the following code to the EnabledChanged event for the CheckBox control.

    Visual Basic
    If CheckBox1.Enabled = False Then
      ' Assign the third image (DisabledPicture) to the Image property.
      CheckBox1.Image = ImageList1.Images(2)
    ElseIf CheckBox1.Checked = True Then
      ' Assign the second image (DownPicture) to the Image property
      CheckBox1.Image = ImageList1.Images(1)
    Else
      ' Assign the first image (Picture)to the Image property
      CheckBox1.Image = ImageList1.Images(0)
    End If

    The application should now behave exactly as it did in Visual Basic 6.0.

See Also

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker