Hide

SftTree/OCX 7.5 - ActiveX Tree Control

Display
Print

ListFont Sample (VB.NET)

This sample illustrates cell fonts.

The source code is located at C:\Program Files (x86)\Softelvdm\SftTree OCX 7.5\Samples\Visual Studio - VB.NET\ListFont\Form1.vb or C:\Program Files\Softelvdm\SftTree OCX 7.5\Samples\Visual Studio - VB.NET\ListFont\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 AxSftTree1_ItemDblClick(ByVal sender As Object, ByVal e As AxSftTreeLib75._DSftTreeEvents_ItemDblClickEvent) Handles AxSftTree1.ItemDblClick
        If e.areaType = SftTreeAreaTypeConstants.constSftTreeColumnRes Then
            AxSftTree1.get_Column(e.colIndex).MakeOptimal()
            AxSftTree1.Items.RecalcHorizontalExtent()
        End If
    End Sub

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

        ' Add all screen fonts to the tree control
        Dim ScreenIndex As Integer
        ScreenIndex = AxSftTree1.Items.Add("Fonts")
        AxSftTree1.get_Item(ScreenIndex).Level = 0

        ' display fonts
        Dim Counter As Integer = 0
        Dim ff As FontFamily
        For Each ff In System.Drawing.FontFamily.Families
            ' add font name
            Dim newFont As Font
            Try
                newFont = New Font(ff.Name, 8)
            Catch
                newFont = Nothing
            End Try
            If Not newFont Is Nothing Then
                Counter = Counter + 1
                If Counter > 50 Then ' only add up to 50
                    Exit For
                End If
                Dim ItemIndex As Integer
                ItemIndex = AxSftTree1.Items.Add(ff.Name)
                AxSftTree1.get_Item(ItemIndex).Level = 1
                ' set the font
                AxSftTree1.get_Cell(ItemIndex, 0).Font = OLECvt.ToIFontDisp(newFont)
                ' set the font name in column 1
                AxSftTree1.get_Cell(ItemIndex, 1).Text = ff.Name
            End If
        Next

        AxSftTree1.BulkUpdate = False
        ' make column widths optimal
        AxSftTree1.ColumnsObj.MakeOptimal()
        ' allow horizontal scrolling
        AxSftTree1.Items.RecalcHorizontalExtent()
    End Sub

End Class

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