Back to Devexpress

How to: Create custom customization form

windowsforms-2198-controls-and-libraries-form-layout-managers-layout-and-data-layout-controls-examples-how-to-create-custom-customization-form.md

latest2.5 KB
Original Source

How to: Create custom customization form

  • Oct 29, 2020
  • 3 minutes to read

You can create a custom Customization Form and use it instead of the standard Customization Form. The custom form can display any elements supported by the default form, and can also provide additional layout customization functionality. This tutorial shows how to create this form.

Basic steps to create a custom Customization Form are as follows:

  • Create a form by deriving it from the DevExpress.XtraLayout.Customization.UserCustomizationForm class.
  • Add any standard control elements supported by the default Customization Form. At design time, you can add it via the form’s context menu.
  • Add custom controls and implement the required functionality.
  • Register the new Customization Form via the LayoutControl.RegisterUserCustomizationForm method.

Design-time Sample

This tutorial shows how to implement a simple Customization Form providing a Restore All button, that allows an end-user to make all hidden items visible.

  1. Create a new form.

  2. Switch to the code designer, and change the form’s ancestor to the UserCustomizationForm class.

  3. Rebuild the project by selecting the Build->Rebuild Solution menu command.

  4. Switch to the designer. Set the form’s caption as required. In this sample, it’s set to “New Customization Form”. Now the form looks like:

  5. Right-click the form to open the context menu, allowing you to add the standard control elements, supported by the default Customization Form:

  6. Add a SimpleButton control at the bottom of the form. Give it the Restore All caption:

  7. Write a Click event handler for the Restore All button as follows:

  8. In the main form’s Layout Control, register the new Customization Form via the LayoutControl.RegisterUserCustomizationForm method:

When running the main form, the new Customization Form can now be opened by right-clicking the Layout Control, and selecting the Customize Layout menu command.

The result is shown in the image below: