Step 6: Outlining

The outlining capabilities of the VSFlexGrid control rely on subtotals. When outlining, each subtotal row is treated as a node that can be collapsed or expanded. Nested subtotals are treated as nested nodes. Any rows that are not subtotal rows are treated as branches, which contain detail data.

Because we have already implemented subtotals, adding the outline capabilities is just a matter of adding one more line of code to the Form_Load event handler. The new code sets the OutlineBar property, which displays a tree structure with buttons that the user may click to collapse or expand the outline. Here is what the Form_Load routine should look like by now:

    Private Sub Form_Load()

   

        ' initialize the control

 

        ' define some sample data

 

        ' populate the control with the data

 

        ' set up cell merging (all columns)

 

        ' set up outlining

        fg.OutlineBar = flexOutlineBarComplete

        ' organize the data

 

    End Sub

That concludes this demo. Run the project one last time and try clicking on the outline buttons. Clicking will toggle the state of the node between collapsed and expanded. Pressing the SHIFT key and clicking or pressing CTRL-SHIFT and clicking will set the outline level for the entire control.