ComponentOne List 8.0 for ActiveX
Tutorial 10 - Using Styles to Highlight Related Data

In this tutorial, you will learn how to change the list's display to highlight rows by defining new styles at run time. True DBList uses Style objects to apply font and color characteristics to rows, columns, and individual cells.

  1. Start with the project used in Tutorial 9.

  2. Add a control array of three command buttons to the form. Change the captions of Command1(0) to Prospective Customers, Command1(1) to Distributors, and Command1(2) to Reset the List so that the form appears as follows.

  3. Add the following declarations to the General section of Form1:

    Example Title
    Copy Code
    Dim ButtonFlag As Integer
    
    Dim Prospective As New TrueDBList80.Style
    
    Dim Distributors As New TrueDBList80.Style
    
  4. Enter the following code in the Click (Visual Basic) event of Command1:

    Example Title
    Copy Code
    Private Sub Command1_Click(Index As Integer)
    
        Select Case Index
    
        Case 0
    
            ButtonFlag = 0
    
            TDBList1.FetchRowStyle = True
    
        Case 1
    
            ButtonFlag = 1
    
            TDBList1.FetchRowStyle = True
    
        Case 2
    
            TDBList1.FetchRowStyle = False
    
        End Select
    
       
    
        TDBList1.Refresh
    
    End Sub
    
  5. Enter the following code in the Form_Load (Visual Basic) event:

    Example Title
    Copy Code
    Private Sub Form_Load()
    
        Set Prospective = TDBList1.Styles.Add("Prospective")
    
        Prospective.Font.Italic = True
    
        Prospective.Font.Bold = True
    
        Prospective.ForeColor = vbBlue
    
       
    
        Set Distributors = TDBList1.Styles.Add("Distributors")
    
        Distributors.BackColor = vbRed
    
        Distributors.ForeColor = vbWhite
    
    End Sub
    
  6. Enter the following code in the FetchRowStyle event of TDBList1:

    Example Title
    Copy Code
    RSClone.Bookmark = Bookmark If ButtonFlag = 0 And RSClone("CustType").Value = 1
                Then RowStyle = Prospective End If If ButtonFlag = 1 And RSClone("CustType").Value = 4 Then RowStyle = Distributors End
                If
    

Run the program and observe the following:

To end the program, press the End button on the Visual Basic toolbar.  You have successfully completed Tutorial 10.

 

 


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

Product Support Forum  |  Documentation Feedback