Skip to main content
Bar

BarItem.Links Property

Gets the collection of links to the bar item.

Namespace: DevExpress.XtraBars

Assembly: DevExpress.XtraBars.v24.1.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

Property Value

Type Description
BarItemLinkCollection

A BarItemLinkCollection object representing the item’s link collection.

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:

Hide Duplicated Bar Item Links

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