ComponentOne List 8.0 for ActiveX
Tutorial 20 - Printing, Print Preview, and Export

In this tutorial, you will learn how to use the printing and exporting capabilities of True DBList.

  1. Start with the project created in Tutorial 1.

  2. Add two command buttons (Command1 and Command2) and a check box (Check1) to the form (Form1).

  3. Set the Click (Visual Basic) property of Command1, Command2, and Check1 to Print Preview, Export HTML, and Export Selected Rows, respectively. Your form should now look like this:

    If you wish to select more than one row, you must also change the MultiSelect property (from the Properties window or the General tab on the Properties Pages dialog box) from the default 0 - None to 2 - Extended.
  4. Enter the following code in the Form_Load (Visual Basic) event:

    Example Title
    Copy Code
    Private Sub Form_Load()
    
    ' Initialize the Data control
    
        Data1.Refresh
    
       
    
    ' Allow user to change the column order
    
        TDBList1.AllowColMove = True
    
       
    
    ' Change the presentation of the list
    
        With TDBList1.Columns
    
            .Item("Country").BackColor = vbCyan
    
            .Item("Country").Font.Name = "Times New Roman"
    
            .Item("Last").NumberFormat = ">"
    
            .Item("Last").ForeColor = vbRed
    
        End With
    
        
    
        With TDBList1.HeadingStyle
    
            .Font.Bold = True
    
            .BackColor = vbBlue
    
            .ForeColor = vbYellow
    
        End With
    
    End Sub
    
  5. Add the following code to Command1 and Command2:

    Example Title
    Copy Code
    Private Sub Command1_Click()
    
        With TDBList1.PrintInfo
    
            ' Set the page header
    
            .PageHeaderFont.Italic = True
    
            .PageHeader = "Composers table"
    
           
    
            ' Column headers will be on every page
    
            .RepeatColumnHeaders = True
    
           
    
            ' Display page numbers (centered)
    
            .PageFooter = "\tPage: \p"
    
            ' Invoke Print Preview
    
            .PrintPreview
    
        End With
    
    End Sub
    
     
    
    Private Sub Command2_Click()
    
    ' Depending on the Check1.Value
    
    ' the list will export all or just selected rows
    
        TDBList1.ExportToFile App.Path & _
    
                    "\Tutor20.html", False, Check1.Value
    
    End Sub
    

Run the program and observe the following:

 

 


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

Product Support Forum  |  Documentation Feedback