Hide

SftBox/OCX 5.0 - Combo Box Control

Display
Print

Using SftBox/OCX with Visual Basic 6

Adding SftBox/OCX To A Project
Special Considerations
- Color Properties

Adding SftBox/OCX To A Project

The SftBox/OCX control must be added to the Toolbox before it can be used in a project. The Toolbox normally displays the standard Visual Basic controls and any other ActiveX controls that have been added previously.

The control is added to the Toolbox using the Project, Components... menu command, which displays the following dialog:

Select the control "SftBox/OCX 5.0 Combo Box Control" by placing a check mark next to it and click OK. This adds the control to the Toolbox. If you don't see the control in the list, make sure Selected Items Only is not checked. Once you click Apply or OK and an error message is displayed, the product SftBox/OCX is not correctly installed or the control may have been unregistered accidentally. Quit Visual Basic and use the entry Maintenance, Register SftBox OCX in Windows Registry in the SftBox OCX 5.0 program group to register the control. Restart Visual Basic and try to add the control to the Toolbox again.

This adds two SftBox/OCX controls to the Toolbox, one for most development tools and one for Internet Explorer. You could use either with Visual Basic. It is recommended to use the regular control.

Now the control can be added to a form by clicking on the SftBox button of the Toolbox.

All required steps have now been completed to use SftBox/OCX.

Add the following sample code to initialize the control:

Private Sub Form_Load()
    Dim ItemIndex As Long
    SftBox1.Items.TreeLineStyle = treeLineStyleSftBoxDotted0
    SftBox1.ButtonStyle = buttonsSftBoxAll
    ItemIndex = SftBox1.Items.Add("Item 1")
    ItemIndex = SftBox1.Items.Add("Item 2")
    SftBox1.Item(ItemIndex).Level = 1
    SftBox1.Cell(ItemIndex, 0).Image.Appearance = sftImageCheckboxYes
    ItemIndex = SftBox1.Items.Add("Item 3")
    SftBox1.Items.Selection = 0
End Sub

You can run the sample application and it displays a simple combo box with three items. The second item has a check box displayed as cell graphic. By implementing the ItemClick event, the check box can be toggled. This is demonstrated in the Pictures sample.

In this example, the control is initialized at run-time using code. Of course it is also possible (and much easier) to set up all properties using the property pages. You can access the property pages by right-clicking on the control and select the Properties... entry of the popup menu.

Please note that you can right-click on a property in a Property Dialog or double-click on the description of a property to access its complete help information.

You may want to change the Style property to choose a suitable basic combo box style. Additional columns can be defined using the Columns.Count property (by displaying the Property Dialog, click on the Columns tab). Also change the Scrollbars property (Attributes tab) to "3 - Both" to display horizontal and vertical scroll bars.

This control has many properties and methods which you can use. This is a very simple example and doesn't even begin to exploit the capabilities of this control. Please take a moment to familiarize yourself with the objects offered by the SftBox/OCX control. Each object represents a specific area of the control and can be fully customized. Also make sure to run the demo which is included with this product and take a look at the included samples.

Special Considerations

Color Properties

The valid range for a color value is 0 to 16,777,215 (&HFFFFFF). The high order byte of a number in this range equals 0; the lower 3 bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively. The red, green, and blue components are each represented by a number between 0 and 255 (&HFF). If the high byte is not 0, the system colors as defined in Control Panel's settings are used. The Windows API GetSysColor defines all valid constants. Please see your development environment's documentation for applicable color constants.

SftBox1.Items.BackColor = vbHighlight
SftBox1.Items.BackColor = vbRed
SftBox1.Items.BackColor = &HFF ' red

Dim c As Long
c = SftBox1.Items.BackColor

Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.