In this next step, we add labels to the hierarchical list box. In this example, columns one through three have the following labels, respectively: Product, Type, Title of Article. To create the labels, we actually use an edit table. Perform the following steps:

  1. Add an Edit Table control. Add an edit table control to the form called ET_LABELS.

  2. In the edit table's Properties dialog box, add two more columns and type in the following for the column headings, respectively: Product, Type, Title of Article

  3. Click the More… button in the Properties dialog box then check Show Column Headings, and clear Row Numbers.

  4. Add a QuickEvent for the edit table's COLSIZE event, to execute the stored procedure, TEST_LB. Parameters for the QuickEvent are: 

    '@SELF'
  5. Format the labels. Resize the edit table vertically so that only the column headings are visible, and horizontally so that it is exactly the same width as the hierarchical list box. Place the edit table just above the hierarchical list box.

  6. Add a QuickEvent for the window's CREATE event. Define a QuickEvent for the window's CREATE event to execute the stored procedure, TEST_LB. No parameters are needed.

  7. Add two CASE statements to the stored procedure. Add the following code to the stored procedure, TEST_LB, to align the labels with the list box contents.

  case ctrlName = ''
     *align labels
      if Event = 'CREATE' then
         Set_Property(WinId: '.ET_LABELS', 'AUTOSIZECOL', 4)
         gosub SetTabs
      end
      
   case ctrlName = 'ET_LABELS'
      gosub SetTabs

At the end of the stored procedure (after return 0) add the following:

SetTabs:
   colWidth = Send_Message(WinId:'.ET_LABELS', 'COLWIDTH', 0)
   colNum = count(colWidth, @fm) + 1
   tabs = ''
   base = 0
   for nC = 1 to colNum
     base = base+colWidth<nC>
     tabs<nC> = base
   next nC
   Set_Property(WinId:'.LB_H', 'TABSTOPS', tabs)
return

The labels in the edit table will be synchronized with the contents of the list box, allowing you to resize the headings and have the contents be resized as well. The form displays as shown below:

  • No labels