ComponentOne List 8.0 for ActiveX
Tutorial 19 - Reusable Layouts

In True DBList, a layout comprises the complete set of properties that define the appearance and behavior of a list, its splits, and its columns. You can save a list layout to a binary file, then reuse it in other projects. At design time, you can store multiple layouts in a single file, then load them as needed in code. You can even store a layout file on a remote computer and have True DBList download it asynchronously, an ideal technique for initializing a list on an HTML page.

In this tutorial, you will learn how to save and retrieve layouts at run time. If you have an Internet connection, you can also retrieve a layout file from the ComponentOne server.

  1. Start with the project created in Tutorial 1.

  2. Add three command buttons (Command1, Command2, Command3) to the form (Form1).

  3. Set the Click (Visual Basic) property of Command1, Command2, and Command3 to Retrieve Layout, Save Layout, and Retrieve Layout, respectively. Your form should now look like this.

  4. Right-click TDBList1 to display its context menu.

  5. Choose Properties to display the Property Pages dialog box. Select the Splits tab. Expand the Splits(00) node and set the AllowColMove property to True.

  6. Add the following code to the Click (Visual Basic) event of Command1, Command2 and Command3:

    Example Title
    Copy Code
    Private Sub Command1_Click()
    
    On Error GoTo Err:
    
    ' Load the layout
    
        TDBList1.LayoutName = "TestLayout"
    
        TDBList1.LayoutFileName = App.Path & "\Tutor19.grx"
    
        TDBList1.LoadLayout
    
        Exit Sub
    
    Err:
    
        MsgBox Err.Description
    
    End Sub
    
    Private Sub Command2_Click()
    
    ' Save current layout
    
        TDBList1.LayoutFileName = App.Path & "\Tutor19.grx"
    
        TDBList1.Layouts.Add "TestLayout"
    
    End Sub
    
    Private Sub Command3_Click()
    
    ' Load layout from ComponentOne
    
        TDBList1.LayoutName = "ComponentOne"
    
     
    
    ' Start the download
    
        TDBList1.LayoutUrl = _
    
            "ftp://ftp.componentone.com/pub/files/tutor19.grx"
    
     
    
    ' Set the order of records (by Country)
    
        Data1.RecordSource = _
    
            "Select * From Composer Order By Country"
    
        Data1.Refresh
    
    End Sub
    
  7. Place the following code in the LayoutReady event of TDBList1:

    Example Title
    Copy Code
    Private Sub TDBList1_LayoutReady()
    
    ' Load layout as soon as it is available
    
        TDBList1.LoadLayout
    
    End Sub
    

Run the program and observe the following:

For more information, see Reusable Layouts.

This concludes Tutorial 19.

 

 


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

Product Support Forum  |  Documentation Feedback