Skip to main content
A newer version of this page is available. .

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.v18.2.dll

Declaration

public class AppMenuFileLabel :
    BaseStyleControl

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.

AppMenuFileLabel_Class

The main features of AppMenuFileLabel objects are listed below. Labels can:

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:

AppMenuFileLabel

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;
    // 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) {
    //...
}
See Also