windowsforms-devexpress-dot-xtralayout-dot-layoutcontrol-7c4efa6f.md
Fires immediately after the Customization Form has been invoked.
Namespace : DevExpress.XtraLayout
Assembly : DevExpress.XtraLayout.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[DXCategory("Action")]
public event EventHandler ShowCustomization
<DXCategory("Action")>
Public Event ShowCustomization As EventHandler
The ShowCustomization event's data class is EventArgs.
Handle the ShowCustomization event to provide an appropriate response to the Customization Form being activated.
For more information, see Customization Form.
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;
}
Imports DevExpress.XtraLayout
Imports DevExpress.XtraLayout.Customization
Public Class MyLayoutControlItemPropertyWrapper
Inherits BasePropertyGridObjectWrapper
Protected ReadOnly Property Item() As LayoutControlItem
Get
Return TryCast(WrappedObject, LayoutControlItem)
End Get
End Property
<DescriptionAttribute("Gets or sets the item's text")> _
Public Property Text() As String
Get
Return Item.Text
End Get
Set(ByVal value As String)
Item.Text = value
End Set
End Property
<DescriptionAttribute("Gets or sets the position of the text region")> _
Public Property TextLocation() As DevExpress.Utils.Locations
Get
Return Item.TextLocation
End Get
Set(ByVal value As DevExpress.Utils.Locations)
Item.TextLocation = value
End Set
End Property
<DescriptionAttribute("Gets or sets whether the text region is visible")> _
Public Property TextVisible() As Boolean
Get
Return Item.TextVisible
End Get
Set(ByVal value As Boolean)
Item.TextVisible = value
End Set
End Property
Public Overrides Function Clone() As BasePropertyGridObjectWrapper
Return New MyLayoutControlItemPropertyWrapper()
End Function
End Class
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
' Associate the wrapper object with LayoutControlItem objects.
LayoutControl1.RegisterCustomPropertyGridWrapper(GetType(LayoutControlItem), _
GetType(MyLayoutControlItemPropertyWrapper))
End Sub
' Show properties in the Property Grid in alphabetical order.
Private Sub LayoutControl1_ShowCustomization(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles LayoutControl1.ShowCustomization
Dim lc As LayoutControl = TryCast(sender, LayoutControl)
Dim form As CustomizationForm = TryCast(lc.CustomizationForm, CustomizationForm)
' Customize the Property Grid's sort settings.
TryCast(form.propertyGridItem.Control, PropertyGrid).PropertySort = PropertySort.Alphabetical
End Sub
End Class
See Also