BarItem.Links Property
In This Article
Gets the collection of links to the bar item.
Namespace: DevExpress.XtraBars
Assembly: DevExpress.XtraBars.v24.2.dll
NuGet Package: DevExpress.Win.Navigation
#Declaration
[Browsable(false)]
public virtual BarItemLinkCollection Links { get; }
#Property Value
Type | Description |
---|---|
Bar |
A Bar |
#Remarks
Use the Links
property to access and manage links that correspond to a bar item. You can add, delete, or customize individual item links.
#Example
This example hides duplicated links (BarItemLink
) based on the selected option:
using System;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Ribbon;
namespace DXApplication {
public partial class Form1 : RibbonForm {
public Form1() {
InitializeComponent();
}
void radioGroup1_SelectedIndexChanged(object sender, EventArgs e) {
ShowAllBarItemLinks();
switch (radioGroup1.SelectedIndex) {
case 1:
ShowBarItemLinks(ribbonPageGroup1.ItemLinks);
break;
case 2:
ShowBarItemLinks(ribbonPageGroup2.ItemLinks);
break;
case 3:
ShowBarItemLinks(ribbonControl1.Toolbar.ItemLinks);
break;
default:
break;
}
}
void ShowBarItemLinks(BarItemLinkCollection links) {
foreach (BarItemLink link in links) {
HideDuplicatedLinks(link.Item, link.LinkedObject);
}
}
void HideDuplicatedLinks(BarItem item, object linkedObject) {
foreach (BarItemLink link in item.Links) {
link.Visible = link.LinkedObject == linkedObject;
}
}
void ShowAllBarItemLinks() {
foreach (BarItem item in ribbonControl1.Items) {
foreach (BarItemLink link in item.Links) {
link.Visible = true;
}
}
}
}
}
See Also