windowsforms-5469-controls-and-libraries-ribbon-bars-and-menu-examples-bars-how-to-create-and-customize-an-item-and-its-item-links.md
The following example shows how you can create and customize an item and its item links.
In this example, a BarButtonItem item is created. Then, two links to this items are added to a bar and submenu. For the second link, a custom caption is assigned. The first link uses the item’s default caption.
//A bar manager providing the XtraBars functionality
BarManager bManager;
//Initialize the bManager object
//...bManager = barManager1;
//Create an item, add it to the bar manager's item collection
BarItem item = new BarButtonItem(bManager, "New");
//Set the bar item's ID to allow the bar's layout to be saved and restored correctly
item.Id = bManager.GetNewItemId();
//A bar to which the item will be added
Bar bar1;
//Initialize the bar1 object
//...bar1 = toolBar1;
//A submenu to which the item will be added
BarSubItem subMenu1;
//Initialize the subMenu1 object
//...subMenu1 = mFile;
//Create a link to the item within the bar
BarItemLink link1 = bar1.AddItem(item);
//Create another link to the item within the submenu
BarItemLink link2 = subMenu1.AddItem(item);
//Change the second link's caption
link2.UserCaption = "Create File...";
'A bar manager providing the XtraBars functionality
Dim bManager As BarManager
'Initialize the bManager object
'...bManager = barManager1
'Create an item, add it to the bar manager's item collection
Dim item As BarItem = New BarButtonItem(bManager, "New")
'Set the bar item's ID to allow the bar's layout to be saved and restored correctly
item.Id = bManager.GetNewItemId()
'A bar to which the item will be added
Dim bar1 As Bar
'Initialize the bar1 object
'...bar1 = toolBar1
'A submenu to which the item will be added
Dim subMenu1 As BarSubItem
'Initialize the subMenu1 object
'...subMenu1 = mFile
'Create a link to the item within the bar
Dim link1 As BarItemLink = bar1.AddItem(item)
'Create another link to the item within the submenu
Dim link2 As BarItemLink = subMenu1.AddItem(item)
'Change the second link's caption
link2.UserCaption = "Create File..."