Export (0) Print
Expand All

Style Property Changes in Visual Basic .NET

In Visual Basic 6.0, setting the Style property of a CommandButton, CheckBox or OptionButton control to 1 – Graphical changed the appearance of the control to display images. The Picture, DownPicture, and DisabledPicture properties were used to assign images to be displayed in response to state changes. For example, when a CheckBox control was checked, the DownPicture image was displayed; if the control was disabled, the DisabledPicture image was displayed.

Visual Basic .NET no longer supports the Style, Picture, DownPicture, or DisabledPicture properties. The Style property is replaced by the Appearance property, the Picture property is replaced by the Image property, and the functionality of the DownPicture and DisabledPicture properties can be emulated using an ImageList control.

When an application is upgraded to Visual Basic .NET, if the Style property is set to 1 – Graphical, the Appearance property of the upgraded control is set to Button, and any image assigned to the Picture property at design time is assigned to the Image property of the upgraded control.

What to do next

  • Check your Visual Basic 6.0 application. If the DownPicture and DisabledPicture properties are not being set at design time or at run time, the behavior should be the same in Visual Basic .NET.
  • If the DownPicture or DisabledPicture properties are being set, take the following steps to modify the upgraded application:
    Note   The following example uses a CheckBox control; the same steps apply for an OptionButton control (replaced by RadioButton control in Visual Basic .NET).
    • Determine the file names and locations of the images that were assigned to the Picture, DownPicture, and DisabledPicture properties and, if necessary, copy them to your development computer.
    • Add an ImageList control from the Toolbox to your form.
    • In the Properties window, select the Images property.
    • In the Image Collection Editor, add the images for the Picture, DownPicture, and DisabledPicture properties, in that order.
    • If any of the properties were set at run time, remove the code.
    • If the properties were set a design time, add the following code to the Load event for the form:
      ' Assign the first image (Picture) to the Image property.
      checkBox1.Image = imageList1.Images(0)
      
    • To display the DownPicture image at run time, add the following code to the CheckChanged event for the CheckBox control:
      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
      
    • To display the DisablePicture image at run time, add the following code to the EnabledChanged event 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.

See Also

CheckBox Control Changes in Visual Basic .NET | CommandButton Control Changes in Visual Basic .NET | OptionButton Control Changes in Visual Basic .NET | UserControl Changes in Visual Basic .NET

Show:
© 2014 Microsoft