Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

NavLinkCollection.Add(NavBarItem) Method

Adds a link to the end of the collection.

Namespace: DevExpress.XtraNavBar

Assembly: DevExpress.XtraNavBar.v24.2.dll

NuGet Package: DevExpress.Win

#Declaration

public virtual NavBarItemLink Add(
    NavBarItem item
)

#Parameters

Name Type Description
item NavBarItem

A NavBarItem object to which the created link refers.

#Returns

Type Description
NavBarItemLink

A NavBarItemLink object representing the added link.

#Remarks

Use the Add method to add a new link to a group. Adjust properties of the obtained object to control the appearance and behavior of the added link.

You can access the collection of group links via the NavBarGroup.ItemLinks property. Groups are obtained via the control’s NavBarControl.Groups property.

#Example

The following sample code demonstrates how to add and modify groups, items and links between them. All elements are added via the Add method of the corresponding collection.

Captions are assigned to the added group and two items. This is performed via the NavElement.Caption property of the NavBarGroup and NavBarItem objects respectively. The NavElement.ImageOptions property is used to display images within links.

The following image shows the control before and after code execution.

GroupsItemsLinks - Adding

using DevExpress.XtraNavBar;
// ...
// Create a new group 
NavBarGroup helpGroup = navBarControl1.Groups.Add();
helpGroup.Caption = "Help Topics";
helpGroup.GroupStyle = NavBarGroupStyle.SmallIconsText;

// Create two items
NavBarItem indexItem = navBarControl1.Items.Add();
indexItem.Caption = "Index";
indexItem.ImageOptions.SmallImage = Image.FromFile("E:\\Images\\Icons\\index.bmp");

NavBarItem contentsItem = navBarControl1.Items.Add();
contentsItem.Caption = "Contents";
contentsItem.ImageOptions.SmallImage = Image.FromFile("E:\\Images\\Icons\\bookclosed.bmp");

// Add the items to the group
helpGroup.ItemLinks.Add(indexItem);
helpGroup.ItemLinks.Add(contentsItem);
See Also