LayoutControl.ShowCustomization Event
Fires immediately after the Customization Form has been invoked.
Namespace: DevExpress.XtraLayout
Assembly: DevExpress.XtraLayout.v24.2.dll
Declaration
Event Data
The ShowCustomization event's data class is EventArgs.
Remarks
Handle the ShowCustomization event to provide an appropriate response to the Customization Form being activated.
For more information, see Customization Form.
Example
The following example shows how to display only specific properties in the Customization Form’s Property Grid, when selecting regular layout items (items of the LayoutControlItem type), and sort these properties in alphabetical order.
To control which properties to display in the Property Grid when selecting layout items, a BasePropertyGridObjectWrapper class descendant is created. In the example, the MyLayoutControlItemPropertyWrapper class is created, introducesingthree public properties: Text, TextLocation and TextVisible. This class is associated with layout items of the LayoutControlItem type via the LayoutControl.RegisterCustomPropertyGridWrapper method. As a result, when selecting any LayoutControlItem object at runtime in customization mode, the Property Grid will display only the public properties specified by the MyLayoutControlItemPropertyWrapper class.
Note
When creating a Wrapper object, the Clone method must be overridden. It must return a copy of the current object.
To display properties in the Property Grid in alphabetical order, the LayoutControl.ShowCustomization
event is handled. In this event handler, the Property Grid control is accessed and its PropertySort property is set to PropertySort.Alphabetical.
using DevExpress.XtraLayout;
using DevExpress.XtraLayout.Customization;
public class MyLayoutControlItemPropertyWrapper : BasePropertyGridObjectWrapper {
protected LayoutControlItem Item {
get { return WrappedObject as LayoutControlItem; }
}
[DescriptionAttribute("Gets or sets the item's text")]
public string Text {
get { return Item.Text; }
set { Item.Text = value; }
}
[DescriptionAttribute("Gets or sets the position of the text region")]
public DevExpress.Utils.Locations TextLocation {
get { return Item.TextLocation; }
set { Item.TextLocation = value; }
}
[DescriptionAttribute("Gets or sets whether the text region is visible")]
public bool TextVisible {
get { return Item.TextVisible; }
set { Item.TextVisible = value; }
}
public override BasePropertyGridObjectWrapper Clone() {
return new MyLayoutControlItemPropertyWrapper();
}
}
private void Form1_Load(object sender, EventArgs e) {
// Associate the wrapper object with LayoutControlItem objects.
layoutControl1.RegisterCustomPropertyGridWrapper(typeof(LayoutControlItem),
typeof(MyLayoutControlItemPropertyWrapper));
}
// Show properties in the Property Grid in alphabetical order.
private void layoutControl1_ShowCustomization(object sender, EventArgs e) {
LayoutControl lc = sender as LayoutControl;
CustomizationForm form = lc.CustomizationForm as CustomizationForm;
// Customize the Property Grid's sort settings.
(form.propertyGridItem.Control as PropertyGrid).PropertySort = PropertySort.Alphabetical;
}