This topic shows how to add treeview items and subtreeview items through code.
To add a PlaceHolder control and add a reference to the C1.Web.Command assembly, complete the following:
1. Add a PlaceHolder control to the web page.
2. Import the C1.Web.Command namespace to your source code.
Imports C1.Web.Command
· C#
using C1.Web.Command;
· Delphi
uses C1.Web.Command;
3. To programmatically create a root and parent item for C1WebTreeView, complete the following:
'First create an instance of the class
Dim treeview As New C1WebTreeView()
'Add the C1WebTreeView control to the PlaceHolder control
PlaceHolder1.Controls.Add(treeview)
'create the C1WebTreeViewItem
Dim item As C1WebTreeViewItem
treeview.Items.Add(New C1WebTreeViewItem("Root Item", "RightFrame.aspx?key=Root Item"))
treeview.Items.Add(New C1WebTreeViewItem("Parent Item"))
· C#
//Create an instance of the class
C1WebTreeView treeview = new C1WebTreeView();
//Add the C1WebTreeView control to the PlaceHolder control
PlaceHolder1.Controls.Add(treeview);
C1WebTreeViewItem item;
treeview.Items.Add(new C1WebTreeViewItem("Root Item", "RightFrame.aspx?key=Root Item"));
treeview.Items.Add(new C1WebTreeViewItem("Parent Item"));
· Delphi
var
item: C1WebTreeViewItem;
treeview: C1WebTreeView;
begin
treeview := C1WebTreeView.Create;
//Add the C1WebTreeView control to the PlaceHolder control
PlaceHolder1.Controls.Add(treeview)
PlaceHolder1.Controls.Add(treeview);
treeview.Items.Add(C1WebTreeViewItem.Create('Root Item', 'RightFrame.aspx?key=Root Item'));
treeview.Items.Add(C1WebTreeViewItem.Create('Parent Item'));
end;
4. To create a C1WebTreeViewGroup and a SubTreeViewItem, use the following code:
'Add the SubTree
item = CType(treeview.Items(1), C1WebTreeViewItem)
' Create subtreeview
item.CreateChildGroup()
' Add subtreeview items under "Parent Item"
item.ChildGroup.Items.Add(New C1WebTreeViewItem("Child Item"))
· C#
//Add the SubTree
item = (C1WebTreeViewItem)treeview.Items[1];
// Create subtreeview
item.CreateChildGroup();
// Add subtreeview items under "Parent Item"
item.ChildGroup.Items.Add(new C1WebTreeViewItem("Child Item"));
· Delphi
begin
//Add the SubTree
item := (C1WebTreeViewItem)treeview.Items[1];
item.CreateChildGroup;
item.ChildGroup.Items.Add(C1WebTreeViewItem.Create('Child Item'));
end;
Send comments about this topic to ComponentOne. Copyright © ComponentOne LLC. All rights reserved. |