Hide

SftBox/OCX 5.0 - Combo Box Control

Display
Print

Features Sample (VB.NET)

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\Visual Studio - VB.NET\Features\Form1.vb or C:\Program Files\Softelvdm\SftBox OCX 5.0\Samples\Visual Studio - VB.NET\Features\Form1.vb (on 32-bit Windows versions).

Private Sub closeButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles closeButton.Click
    Application.Exit()
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    BoldFont = New Font(SftBox1.Font, FontStyle.Bold)
    ItalicFont = New Font("Arial", 8, FontStyle.Italic)

    Dim index As Integer
    SftBox1.BulkUpdate = True
    For index = 0 To 29
        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
    SftBox1.BulkUpdate = False

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

Private Function AddOneItem(ByVal Cell0 As String, ByVal Cell1 As String, ByVal Cell2 As String) As Integer
    Dim index As Integer
    index = SftBox1.Items.Add(Cell0)
    SftBox1.get_Cell(index, 1).Text = Cell1
    If index Mod 4 = 0 Then
        SftBox1.get_Cell(index, 1).Image.NETImageObject = pictureSpecial.Image
        If index Mod 8 = 0 Then SftBox1.get_Cell(index, 1).ImageHAlign = SftBoxHAlignConstants.halignSftBoxRight
    End If
    SftBox1.get_Cell(index, 2).Text = Cell2
    If index Mod 5 = 0 Then
        SftBox1.get_Cell(index, 2).Image.NETImageObject = picturePin.Image
        If index Mod 10 = 0 Then SftBox1.get_Cell(index, 2).ImageHAlign = SftBoxHAlignConstants.halignSftBoxRight
    End If
    If index Mod 3 = 0 Then
        SftBox1.get_Item(index).RowHeader.Image.NETImageObject = picturePic.Image
        If index Mod 6 = 0 Then SftBox1.get_Item(index).RowHeader.ImageHAlign = SftBoxHAlignConstants.halignSftBoxRight
    End If
    If index Mod 6 = 0 Then SftBox1.get_Cell(index, 0).Font = OLECvt.ToIFontDisp(BoldFont)
    If index Mod 7 = 0 Then SftBox1.get_Cell(index, 1).Font = OLECvt.ToIFontDisp(ItalicFont)
    AddOneItem = index
End Function

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