windowsforms-devexpress-dot-xtranavbar-dot-navelement.md
Gets or sets the element’s caption.
Namespace : DevExpress.XtraNavBar
Assembly : DevExpress.XtraNavBar.v25.2.dll
NuGet Package : DevExpress.Win
[XtraSerializableProperty]
public virtual string Caption { get; set; }
<XtraSerializableProperty>
Public Overridable Property Caption As String
| Type | Description |
|---|---|
| String |
A string value specifying element caption.
|
If the HTML formatting feature is enabled (see NavBarControl.AllowHtmlString and NavElement.AllowHtmlString), you can use HTML tags to format the NavElement.Caption. For detailed information, see HTML Text Formatting.
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.
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);
Imports DevExpress.XtraNavBar
' ...
' Create a new group
Dim HelpGroup As NavBarGroup = NavBarControl1.Groups.Add
HelpGroup.Caption = "Help Topics"
HelpGroup.GroupStyle = NavBarGroupStyle.SmallIconsText
' Create two items
Dim IndexItem As NavBarItem = NavBarControl1.Items.Add
IndexItem.Caption = "Index"
IndexItem.ImageOptions.SmallImage = Image.FromFile("E:\Images\Icons\index.bmp")
Dim ContentsItem As NavBarItem = 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