ComponentOne List 8.0 for ActiveX
Tutorial 16 - Displaying Array Data in Unbound Storage Mode

In this tutorial, you will learn how to use the unbound storage mode (DataMode property set to 4 - Storage) of True DBList to display an array of strings. Unlike unbound (extended) and application modes, storage mode does not fire data-gathering events. Instead, it uses an XArrayDB ActiveX object to store, access, and maintain data.

In code, you create, re-dimension, and populate an XArrayDB object with your data just as you would a Visual Basic array, then assign the XArrayDB object to the Array property of the list or combo. The data will then be maintained and exchanged between the list and the XArrayDB object automatically. There are no unbound events to write, making this mode the easiest to use.

  1. Start a new project.

  2. Place a True DBCombo control (TDBCombo1) on the form (Form1).

  3. Set the DataMode property of TDBCombo1 to 4 - Storage (the default value of this property is 0 - Bound) and the MaxComboItems property to 14.

    Configuring the combo at design time

    We shall configure the combo to display four columns.

  4. Right-click TDBCombo1 to display its context menu, and choose the Edit option. The combo will enter its visual editing mode, enabling you to interactively change the combo's row and column layout.

  5. By default, the combo contains two columns. We are going to create two more. Right-click anywhere in the combo to display the visual editing menu. Choose the Append command to add a new column at the end of the combo. Execute this command again to get a total of four columns.

  6. Right-click TDBCombo1 to display its context menu. Choose Properties to display the Property Pages dialog box.

  7. Click the Columns tab to display a list of the available columns, designated as Columns(00) through Columns(03). Expand the Columns(00) node and set its Caption property to Column 0. Repeat the process for the remaining columns.

    Adding XArrayDB to the project

    Before writing the code, we need to add the ComponentOne XArrayDB Object to the project.

  8. Select References from the Project menu to display a list of available type library references. Select the check box labeled ComponentOne XArrayDB Object (XARRAYDB.OCX), and then press the OK button.

    Initializing the array data

    Next, we create the XArrayDB object in code.

  9. In the General section of Form1, insert the following declarations:

    Example Title
    Copy Code
    ' General declarations
    
    Option Explicit
    
    Dim Sink As New XArrayDB
    
  10. In the Form_Load (Visual Basic) event, we ReDim the XArrayDB to contain 100 rows and 4 columns. After populating the XArrayDB, we assign it to the combo's Array property.

    Example Title
    Copy Code
    Private Sub Form_Load()
    
     
    
        ' Allocate space for 100 rows, 4 columns
    
        Sink.ReDim 0, 99, 0, 3
    
     
    
        Dim row, col As Long
    
     
    
        ' The LowerBound and UpperBound properties correspond
    
        ' to the LBound and UBound functions in Visual Basic.
    
        ' Hard-coded dimensions can be used instead, if known.
    
        For row = Sink.LowerBound(1) To Sink.UpperBound(1)
    
            For col = Sink.LowerBound(2) To Sink.UpperBound(2)
    
                Sink(row, col) = "Row " & row & ", Col " & col
    
            Next col
    
        Next row
    
     
    
        ' Bind TDBCombo Control to this XArray instance
    
        Set TDBCombo1.Array = Sink
    
       
    
    End Sub
    

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 16.

 

 


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

Product Support Forum  |  Documentation Feedback