AppMenuFileLabel Class
A label that imitates an item in the Recent Documents pane in MS Office 2007 UI. This is a custom-made control designed for the Ribbon Simple Pad demo, and is not included in the official WinForms Controls line-up. User discretion is advised. We recommend that you use the RecentItemControl instead.
Namespace: DevExpress.XtraBars.Ribbon
Assembly: DevExpress.XtraBars.v24.2.dll
Declaration
Remarks
Labels represented by the AppMenuFileLabel class imitate links to recently used documents in MS Office 2007 UI. You can add these links to any control container. For example, you can use them within the right pane of an ApplicationMenu.
The main features of AppMenuFileLabel objects are listed below. Labels can:
- Display a caption specified by the AppMenuFileLabel.Caption property. An end-user can click the caption, invoking the AppMenuFileLabel.LabelClick event. This is the event generally used to invoke the label’s functionality.
Display a check button at the label’s right edge (use AppMenuFileLabel.ShowCheckButton). An end-user can click this button independently of the caption, toggling the button’s state. Depending on the button’s state, the button displays either AppMenuFileLabel.Image or AppMenuFileLabel.SelectedImage. The AppMenuFileLabel.LabelImageClick and AppMenuFileLabel.CheckedChanged events allow you to respond to clicking this button.
You can use this feature to implement Pin buttons.
- Display a description (AppMenuFileLabel.Text). When specified, it follows the label’s caption.
- Display an image (AppMenuFileLabel.Glyph) at the left of the label’s caption.
Example
The following example shows how to add a label used to represent a link to a file. The label will be displayed in the right pane of an ApplicationMenu within a RibbonForm:
It’s assumed that ApplicationMenu and PopupControlContainer components have been added to the form. The ApplicationMenu is assigned to the RibbonControl.ApplicationButtonDropDownControl property, so it will be displayed when the Application Button is clicked. The PopupControlContainer is assigned to the ApplicationMenu.RightPaneControlContainer property, and it will be displayed within the menu’s right pane.
In the example, an AppMenuFileLabel
object is used to represent a link to a file. These object types imitate links to recent documents found in MS Offfice 2007 UI.
An AppMenuFileLabel
object is customized and added to the created PopupControlContainer, so it will be displayed in the right pane of the Application Menu. The label displays a file’s name and a check button used to toggle the label’s check state. In the image above, the label is in the unchecked state and the check button displays an image specified by the AppMenuFileLabel.Image property.
The AppMenuFileLabel.LabelClick event is handled to respond to a label click. For instance, you can analyze the label’s Tag property, which in this example stores the file’s full path, and then open this file in your application.
using DevExpress.XtraBars.Ribbon;
private void Form1_Load(object sender, EventArgs e) {
// Associate an ApplicationMenu with the RibbonForm's ApplicationButton.
RibbonControl1.ApplicationButtonDropDownControl = applicationMenu1;
// Add an item to the menu.
BarButtonItem barButtonItem1 = new BarButtonItem(RibbonControl1.Manager, "Menu Item");
applicationMenu1.ItemLinks.Add(barButtonItem1);
// Enable the right pane in the Application Menu
applicationMenu1.ShowRightPane = true;
// Specify the container to be displayed within the right pane.
applicationMenu1.RightPaneControlContainer = popupControlContainer1;
// Create a label representing the "Document1.rtf" file.
AppMenuFileLabel label1 = new AppMenuFileLabel();
// Images representing the label's unchecked and checked states.
Image labelUncheckedImage = imageCollection3.Images[1];
Image labelCheckedImage = imageCollection3.Images[0];
// Customize the label's settings.
label1.Dock = DockStyle.Top;
label1.AutoHeight = true;
label1.Caption = "Document1.rtf";
label1.ShowCheckButton = true;
label1.Image = labelUncheckedImage;
label1.SelectedImage = labelCheckedImage;
// Fires when the label is clicked
label1.LabelClick += new EventHandler(label1_LabelClick);
// Custom data associated with the label.
// It can be used to identify the label in the LabelClick event.
label1.Tag = "c:\\My Documents\\Document1.rtf";
// Add the label to the container.
popupControlContainer1.Controls.Add(label1);
}
// Respond to clicking a label.
void label1_LabelClick(object sender, EventArgs e) {
//...
}