ActiveReports 6 Online Help
Use Custom Controls on Reports (TreeView)

Show AllShow All
Hide AllHide All

ActiveReports allows you to drop a third party control onto a report where it is recognized as a custom control. You can access its properties using type casting. In this case, we use hidden textboxes to populate a Visual Studio TreeView control.

Tip: To access properties of a custom control, you should use type casting (for the samples of code, see To access the TreeView control properties in code and assign data section below).

To add the TreeView control to a report

  1. From the Visual Studio toolbox Common Controls tab, drag the TreeView control onto the detail section of a report.
  2. Notice that in the Properties window, the control is called CustomControl1.

To add data and hidden textboxes to the report

  1. Connect the report to the sample nwind.mdb. (For help with this, see the Bind Reports to a Data Source topic.)
  2. In the Query field, enter the following SQL query
    SQL Query
    Copy Code
    SELECT * FROM Orders ORDER BY ShipCountry, ShipCity, CustomerID, EmployeeID
  3. From the Report Explorer, drag the following fields onto the detail section of the report:
    • ShipCountry
    • ShipCity
    • CustomerID
    • EmployeeID
  4. Select all four textboxes, and in the Properties window, change the Visible property to False.

To create a function to add nodes to the TreeView control

  1. Right-click the report and select View Code.
  2. Add a function to the report to add nodes to the TreeView.

The following examples show what the code for the function looks like.

To write the code in Visual Basic.NET

To write the code in C#

To access the TreeView control properties in code and assign data

  1. Back in the design view of the report, double-click the detail section to create an event-handling method for the Detail Format event.
  2. Add code to the handler to access the TreeView properties and assign data from the hidden textboxes.

The following example shows what the code for the method looks like.

To write the code in Visual Basic.NET

To write the code in C#

See Also

Walkthroughs