New to Telerik UI for WinFormsStart a free 30-day trial

Properties, Events and Attributes

Updated over 6 months ago

RadDataLayout exposes properties and events which are similar to the ones provided by the RadDataEntry control.

Properties

PropertyDescription
DataSourceThrough this property user can set the business object or a collection of objects that should be edited. When this property is set RadDataLayout generates editors for each public property which does not have its Browsable attribute set to false.
ColumnCountControls the amount of columns that RadDataLayout will use to arrange the generated controls. Default value is one.
FlowDirectionDefines the direction the editors will be generated.
ItemDefaultHeightSets the height that generated items should have, the default value is 26.
AutoSizeLabelsBy default, the property value is false and the labels width will equals the longest label width. If you set this property to true, the labels will be sized according to their content.
ShowValidationPanelGets or sets a value indicating whether the validation panel should appear.
ItemDefaultHeightSets the height that generated items should have.

Events

There are several events that you will find useful in the context of RadDataLayout:

EventDescription
EditorInitializingOccurs when editor is being initialized. In this event you can change the default editors with custom ones.
EditorInitializedRaised when the editor is initialized.
BindingCreatingOccurs when a binding object for an editor is about to be created. This event is cancelable.
BindingCreatedOccurs when binding object is created.
ItemInitializingThis event is fired when the panel that contains the label, editor and validation label is about to be initialized. This event is cancelable.
ItemInitializedFires when the item is already initialized.
ItemValidatingThis event is raised when any of the generated editors fires its Validating event.
ItemValidatedOccurs when any of the generated editors fires its Validated event.

Attributes

RadDataLayout has support for several attributes that can be used to change the behavior of the control.

AttributeDescription
BrowsableDefines which properties should be displayed.
DisplayNameDetermines what text should be displayed in the label that is associated with the editor.
RadRangeAttributeDefines a range that can be used into validation process. This attribute is provided in validation events.
__ReadOnlyAttribute __Determines whether a property can be edited in RadDataLayout or not.

The Browsable attribute set to false will make the property on which it is used not bindable. This will prevent other controls which use the CurrencyManager object for extracting properties to bind to such a class. A suitable solution for this scenario is to leave the property Browsable set to true and handle the RadDataLayout.ItemInitializing setting the e.Cancel property to true for items which need to hidden in RadDataLayout.

Figure 1: Model With Attributes

WinForms RadDataLayout Model With Attributes

Using attributes.

C#
public class Employee
{
    public string FirstName { get; set; }
    [DisplayName("Family Name")]
    public string LastName { get; set; }
    [Browsable(false)]
    public string Occupation { get; set; }
    [RadRange(2000, 3000)]
    public int Salary { get; set; }
    public DateTime StartingDate { get; set; }
}

See Also