ComponentOne List 8.0 for ActiveX
Tutorial 21 - Cell Bordering and Scroll Tips/Tracking

In this tutorial you will utilize the Cell Border, Scroll Tips and Scroll Tracking features in True DBList. The Cell Border feature allows you to manipulate border options at runtime, while the Scroll Tips and Scroll Tracking features allow you to track the location of your scroll bar and give the user an informational pop-up as the scroll bar moves.

  1. Start a new project.

  2. Based on the following illustration, place these three controls on the form: a True DBList control (TDBList1), an Data control (Data1), a Common Dialog control (Cdlg).

    Next, below the data control, place a control array of check boxes named chkBorderType (0-3), where Top is 0, Left is 1, Bottom is 2 and Right is 3. Set the captions accordingly and set the Alignment property of the Left check box to 1 - Right Justify.

    To the right of the check boxes, place two combo boxes. Name the first one cboBorderAppearance and set its Text property to Border Appearance. Name the second one cboBorderSize and set its Text property to Border Size.

    Add a command button named cmdColor and set its Caption to Border Color.

    Finally, add a frame and place two check boxes (chkSTips and chkSTracking) inside it. Set the Caption properties as shown in the illustration.

  3. Next we will connect Data1 to the TDBLDemo database in code by adding the following code:

    Private Sub Form_Load()

        Dim path As String

        On Error Resume Next

     

        path = App.path & "\..\..\TDBLDemo.mdb" 'database path

        

        'use run time connection

        With Data1

            .DatabaseName = path

            .RecordSource = "composer"

            .Refresh

        End With

       

        cdlg.Color = vbGreen

        cboBorderAppearance.ListIndex = 3

        cboBorderSize.ListIndex = 5

       

        With TDBList1

            .RowHeight = 400

            .RowDividerStyle = 7 'custom style

            .RowDividerColor = vbGreen

        End With

       

    End Sub

  4. Set the TDBList1 RowSource to Data1.

  5. Set the List property of cboBorderAppearance to:

    Flat (Default)

    3D Raised

    3D Inset

    3D Raised Bevel

    3D Inset Bevel

    With the following code:

    Private Sub cboBorderAppearance_Click()

        Call setStyle

    End Sub

  6. Set the List property of cboBorderSize to 0 through 6 and add the following code:

    Private Sub cboBorderSize_Click()

        Call setStyle

    End Sub

  7. Add the following code to cmdColor:

    Private Sub cmdColor_Click()

        cdlg.ShowColor

        Call setStyle

    End Sub

  8. 8.   Add the following code to chkSTracking:

    Private Sub chkSTracking_Click()

        TDBList1.ScrollTrack = chkSTracking.Value

    End Sub

  9. Add the following code to chkSTips:

    Private Sub chkSTips_Click()

        TDBList1.ScrollTips = chkSTips.Value

    End Sub

  10. Add the following code:

    Option Explicit

    Dim recset As Recordset

     

    Dim border As TrueDBList70.BorderStyleConstants

     

    Private Sub chkBorderType_Click(Index As Integer)

        Dim chk As CheckBox

       

        border = dblBorderNone

       

        For Each chk In chkBorderType

            If chk.Value Then

                Select Case chk.Index

                Case 0:

                    border = border Or dblBorderTop

                Case 1:

                    border = border Or dblBorderLeft

                Case 2:

                    border = border Or dblBorderBottom

                Case 3:

                    border = border Or dblBorderRight

                End Select

            End If

        Next chk

       

        Call setStyle

    End Sub

     

    Private Sub Form_Activate()

        'set the recordset in Active event instead of Load event

        Set recset = Data1.Recordset

    End Sub

     

    Private Sub setStyle()

        cmdColor.BackColor = cdlg.Color

        With TDBList1.Columns(TDBList1.Col).Style

            .BorderSize = IIf(cboBorderSize.ListIndex < 0, 0, cboBorderSize.ListIndex)

            .BorderColor = cdlg.Color

            .BorderType = border

            .BorderAppearance = IIf(cboBorderAppearance.ListIndex < 0, 0, cboBorderAppearance.ListIndex)

        End With

    End Sub

     

    Private Sub TDBList1_FetchScrollTips(ByVal ColIndex As Integer, Bookmark As Variant, ByVal ScrollBar As TrueDBList70.ScrollBarsConstants, ScrollTip As String, ByVal TipStyle As TrueDBList70.StyleDisp)

    ' Set the ScrollTip depending on which

    ' scroll bar was moved

        Select Case ScrollBar

        Case dblVertical:

            recset.Bookmark = Bookmark

            ScrollTip = "Record: " & CStr(recset.AbsolutePosition) & " of " & _

            CStr(recset.RecordCount) & vbCrLf & "Last Name: " & _

            recset("Last") & vbCrLf & "First Name: " & recset("First")

           

        Case dblHorizontal:

            ScrollTip = TDBList1.Columns(ColIndex).Caption

        End Select

     

        TipStyle.ForeColor = vbBlue

    End Sub

Run the program and observe the following:

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback