Skip to main content
Bar

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

BarItem.Links Property

Gets the collection of links to the bar item.

Namespace: DevExpress.XtraBars

Assembly: DevExpress.XtraBars.v24.2.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:

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