ComponentOne WebMenus and WebBars for ASP.NET: WebMenus and WebBars for ASP.NET Task-Based Help > C1WebToolBar Tasks > Creating a C1WebToolBar Programmatically

Creating a C1WebToolBar Programmatically

To programmatically create a toolbar and toolbar item , complete the following:

1.   Add a PlaceHolder control to the Web page.

2.   Import the C1.Web.Command namespace to your source code.

      Visual Basic

Imports C1.Web.Command

      C#

using C1.Web.Command;

To programmatically create a C1WebToolBarGroup, use the following code:

      Visual Basic

'First create an instance of the class

Dim toolbar As New C1.Web.Command.C1WebToolBar()

'Add the toolbar to the placeholder control

PlaceHolder1.Controls.Add(toolbar)

'create the C1WebToolBarGroup

toolbar.Groups.Add(New C1WebToolBarGroup())

      C#

//First create an instance of the class

C1WebToolBarGroup toolbar = new C1WebToolBarGroup();

//Add the topicbar to the placeholder control

PlaceHolder1.Controls.Add(toolbar);

//Create the C1WebToolBarGroup

toolbar.Groups.Add(new C1WebToolBarGroup());

3.   To programmatically add a C1WebToolBarItem to C1WebToolBar, use the following code:

      Visual Basic

' Create the C1WebToolBarItem

toolbar.Groups(0).Items.Add(New C1WebToolBarItem("Item 1"))

      C#

//Create the C1WebToolBarItem

toolbar.Groups[0].Items.Add(new C1WebToolBarItem("Item 1"));


Send comments about this topic to ComponentOne.
Copyright © 1987-2009 ComponentOne LLC. All rights reserved.