In a section report, ActiveReports allows you to drop a third party control onto the report design surface where it is recognized as a custom control. You can access its properties using type casting.
In the following steps, we use hidden textbox controls to populate a Visual Studio TreeView control. These steps assume that you have already added a Section Report (code-based) template in a Visual Studio project. See Basic Concepts for more information.
The following examples show what the code for the function looks like.
To write the code in Visual Basic.NET
| Visual Basic.NET code. Paste INSIDE the report class. |
Copy Code
|
|---|---|
Private Function AddNodeToTreeView(ByVal colNodes As TreeNodeCollection, ByVal sText As String) As TreeNode Dim objTreeNode As TreeNode objTreeNode = New TreeNode(sText) colNodes.Add(objTreeNode) Return objTreeNode End Function |
|
To write the code in C#
| C# code. Paste INSIDE the report class. |
Copy Code
|
|---|---|
private TreeNode AddNodeToTreeView(TreeNodeCollection colNodes, string sText)
{
TreeNode objTreeNode;
objTreeNode = new TreeNode(sText);
colNodes.Add(objTreeNode);
return objTreeNode;
}
|
|
The following example shows what the code for the method looks like.
To write the code in Visual Basic.NET
| Visual Basic.NET code. Paste INSIDE the Detail Format event. |
Copy Code
|
|---|---|
|
'Type cast the custom control as a TreeView 'Create a tree node 'Create a second top-level node |
|
To write the code in C#
| C# code. Paste INSIDE the Detail Format event. |
Copy Code
|
|---|---|
//Type cast the custom control as a TreeView |
|
To write code in Visual Basic.NET
| Visual Basic.NET code. Paste INSIDE the Form Load event |
Copy Code
|
|---|---|
| Dim ar = New SectionReport1() ar.Run(False) viewer1.LoadDocument(ar.Document) |
|
To write code in C#
| C# code. Paste INSIDE the Form Load event |
Copy Code
|
|---|---|
| var ar = new SectionReport1(); ar.Run(false); viewer1.LoadDocument(ar.Document); |
|