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 2008 you can achieve the same effect using an ImageList control as outlined in the following example.
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 2008.
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.
Take the following steps to modify the upgraded application if the DownPicture or DisabledPicture properties are set.
To emulate a tri-state control
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.
From the Toolbox, add an ImageList control to your form.
In the Properties window, select the Images property.
In the Image Collection editor, add three images to be used for the Picture, then the DownPicture, and then the DisabledPicture.
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:
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.