Bar

BarManager.CreateCustomizationForm Event

Occurs before the Customization Window is displayed.

Namespace: DevExpress.XtraBars

Assembly: DevExpress.XtraBars.v20.1.dll

Declaration

[DXCategory("Events")]
public event CreateCustomizationFormEventHandler CreateCustomizationForm
<DXCategory("Events")>
Public Event CreateCustomizationForm As CreateCustomizationFormEventHandler

Event Data

The CreateCustomizationForm event's data class is CreateCustomizationFormEventArgs. The following properties provide information specific to this event:

Property Description
CustomizationForm Gets or sets the dialog used as a Customization Form for a specific BarManager.

Remarks

Use this event to replace the default Customization Window with your own. To do so, assign your own customization dialog to the event's CreateCustomizationFormEventArgs.CustomizationForm parameter.

For more information about the default Customization Window, see the Runtime Customization document.

Examples

The following example shows how to change the default Customization Form's behavior by handling the BarManager.CreateCustomizationForm event. In the example, the default Reset button within the Customization Form is replaced with a new "Custom Reset" button.

To change the default Customization Form's behavior, a new Customization Form is created by inheriting from the CustomizationForm class. By default, this form serves as a container for a tabbed control (CustomizationControl) that displays the Toolbars, Commands and Options pages. This control is assigned to the form when the form is created. In some cases, you may want to derive from the CustomizationControl class to change its appearance and then supply this custom control to your custom Customization Form.

In this example, the custom CustomizationForm uses the default CustomizationControl object. The default Reset button is hidden, and a new "Custom Reset" button is created at the default Reset button position.

using DevExpress.XtraBars.Customization;
using DevExpress.XtraBars.Localization;
using DevExpress.LookAndFeel;
using DevExpress.XtraEditors;
using DevExpress.XtraBars;

private void Form1_Load(object sender, EventArgs e) {
    barManager1.CreateCustomizationForm += new CreateCustomizationFormEventHandler(barManager1_CreateCustomizationForm);
}

private void barManager1_CreateCustomizationForm(object sender, CreateCustomizationFormEventArgs e) {
    BarManager barManager = sender as BarManager;
    e.CustomizationForm = new MyCustomizationForm(BarLocalizer.Active.Customization.Clone(), barManager.GetController().LookAndFeel.ActiveLookAndFeel);
}

class MyCustomizationForm : CustomizationForm {
    public MyCustomizationForm(CustomizationControl customizationControl, UserLookAndFeel lookAndFeel)
        : base(customizationControl, lookAndFeel) {
    }

    public override void Init(DevExpress.XtraBars.BarManager manager) {
        base.Init(manager);
        // Access and hide the default Reset button.
        SimpleButton btnReset = localizationManager.btResetBar;
        btnReset.Visible = false;
        // Create a new button that will be displayed at the position of the default Reset button.
        SimpleButton btnNewReset = new SimpleButton();
        btnNewReset.Text = "Custom Reset";
        btnNewReset.Parent = btnReset.Parent;
        btnNewReset.Size = btnReset.Size;
        btnNewReset.Location = btnReset.Location;
        btnNewReset.Click += new EventHandler(btnNewResetBar_Click);
    }

    void btnNewResetBar_Click(object sender, EventArgs e) {
        //...
        MessageBox.Show("Custom reset");
    }
}
See Also