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 ancontrol 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 2005.
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.
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
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 theproperty.
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 theevent for the form:
To display the DownPicture image at run time, add the following code to theevent for the control.
To display the DisabledPicture image at run time, add the following code to theevent for the CheckBox control.
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.