Hide

SftBox/OCX 5.0 - Combo Box Control

Display
Print

Features Sample (VB6)

This sample illustrates a simple combo box with fonts, bitmaps.

The source code is located at C:\Program Files (x86)\Softelvdm\SftBox OCX 5.0\Samples\VB6\Features\Form1.frm or C:\Program Files\Softelvdm\SftBox OCX 5.0\Samples\VB6\Features\Form1.frm (on 32-bit Windows versions).

Option Explicit

Private Function AddOneItem(ByVal Cell0 As String, ByVal Cell1 As String, ByVal Cell2 As String) As Long
    AddOneItem = SftBox1.Items.Add(Cell0)
     SftBox1.Cell(AddOneItem, 1).Text = Cell1
     If (AddOneItem Mod 4) = 0 Then
         Set SftBox1.Cell(AddOneItem, 1).Image.Picture = PictureSpecial.Picture
         If (AddOneItem Mod 8) = 0 Then
             SftBox1.Cell(AddOneItem, 1).ImageHAlign = halignSftBoxRight
         End If
     End If
     SftBox1.Cell(AddOneItem, 2).Text = Cell2
     If (AddOneItem Mod 5) = 0 Then
         Set SftBox1.Cell(AddOneItem, 2).Image.Picture = PicturePin.Picture
         If (AddOneItem Mod 10) <> 0 Then
             SftBox1.Cell(AddOneItem, 2).ImageHAlign = halignSftBoxRight
         End If
     End If
     If (AddOneItem Mod 3) = 0 Then
         Set SftBox1.Item(AddOneItem).RowHeader.Image.Picture = PicturePic.Picture
         If (AddOneItem Mod 6) <> 0 Then
             SftBox1.Item(AddOneItem).RowHeader.ImageHAlign = halignSftBoxRight
         End If
    End If
    If (AddOneItem Mod 6) = 0 Then
        SftBox1.Cell(AddOneItem, 0).Font.Bold = True
    End If
    If (AddOneItem Mod 7) = 0 Then
        SftBox1.Cell(AddOneItem, 1).Font.Italic = True
    End If
End Function


Private Sub Command1_Click()
    Unload Form1
End Sub

Private Sub Form_Load()
    Dim Index As Long
    SftBox1.BulkUpdate = True
    With SftBox1.Items
        For Index = 0 To 30
            If Index = 4 Then
                AddOneItem "Item " & Index, "This cell text is very long", "Cell " & Index & ",2"
            ElseIf Index = 7 Then
                AddOneItem "Item " & Index, "Cell " & Index & ",1", "This cell text is also very long"
            Else
                AddOneItem "Item " & Index, "Cell " & Index & ",1", "Cell " & Index & ",2"
            End If
        Next
    End With
    SftBox1.BulkUpdate = False

    SftBox1.Column(0).Width = SftBox1.Width / 4
    SftBox1.Column(1).Width = SftBox1.Width / 4
    SftBox1.RowHeaders.MakeOptimal 0
    SftBox1.Column(2).MakeOptimal 0
    SftBox1.Items.RecalcHorizontalExtent 0
End Sub

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