New to Telerik UI for WinForms? Download free 30-day trial

Attributes

This article contains a list of some of the more important and more commonly used attributes used with RadPropertyGrid.

EditorAttribute

With the editor attribute you can specify UITypeEditor as well as BaseInputEditor to be used for a given property.


[Editor(typeof(PropertyGridBrowseEditor), typeof(BaseInputEditor))] 
public string FileLocation { get; set; }

Figure 1: EditorAttribute

WinForms RadPropertyGrid EditorAttribute

RadRangeAttribute

The range attribute allows you to set a minimum and maximum value to be used for a property that is edited with a RadSpinEditor.


[RadRange(1, 5)]
public byte DoorsCount { get; set; }

Figure 2: RadRangeAttribute

WinForms RadPropertyGrid RadRangeAttribute

BrowsableAttribute

Determines whether the property will be included in the collection of properties RadPropertyGridSHows.


[Browsable(false)]
public int MyHiddenProperty { get; set; }

public int MyBrowsableProperty { get; set; }

Figure 3: BrowsableAttribute

WinForms RadPropertyGrid BrowsableAttribute

ReadOnlyAttribute

Determines whether a property can be edited in RadPropertyGrid or not.


[ReadOnly(true)]
public int Count { get; set; }

DisplayNameAttribute

Determines the text that will be show for a given property. You can also alter the text for a property by setting its Label.


[DisplayName("PropertyNameInGerman")]
public double PropertyName { get; set; }

Figure 4: DisplayNameAttribute

WinForms RadPropertyGrid DisplayNameAttribute

DescriptionAttribute

Defines the text that is displayed for a given property in the help bar of RadPropertyGrid.


[Description("The manufacturer of the item")] 
public string Manufacturer { get; set; }

Figure 5: DisplayNameAttribute

WinForms RadPropertyGrid DisplayNameAttribute

PasswordPropertyTextAttribute

Determines whether a text property will be edited as a password.


public string Username { get; set; }
[PasswordPropertyText(true)]
public string Password { get; set; }

Figure 6: PasswordPropertyTextAttribute

WinForms RadPropertyGrid PasswordPropertyTextAttribute

DefaultValueAttribute

Defines the default value to which the property will reset. When the property value is set to something different that the default value, it will be marked as modified.

[DefaultValue(1.35)]
public double Length { get; set; }

Figure 7: DefaultValueAttribute

WinForms RadPropertyGrid DefaultValueAttribute

CategoryAttribute

Defines the category to which the property will be grouped when properties are shown categorized. Any property that does not have this attribute will be categorized in the Misc category.


[Category("CategoryName")]
public string CategorizedProperty { get; set; }

public string UncategorizedProperty { get; set; }

Figure 8: CategoryAttribute

WinForms RadPropertyGrid CategoryAttribute

RadSortOrderAttribute

Defines the order in which items would be ordered when no other ordering is applied (Alphabetical or Categorical alphabetical). The order can also be manipulated through the SortOrder property of PropertyGridItem. Setting the property would override the value from the attribute.


[RadSortOrder(2)]
public string AProperty { get; set; }
[RadSortOrder(1)]
public string BProperty { get; set; }
[RadSortOrder(0)]
public string CProperty { get; set; }

Figure 9: RadSortOrderAttribute

WinForms RadPropertyGrid RadSortOrderAttribute

RadCheckBoxThreeStateAttribute

The RadCheckBoxThreeStateAttribute determines whether properties inside RadPropertyGrid, for which a PropertyGridCheckBoxItemElement is created, will have a three state check box editor or a two state one.

[RadCheckBoxThreeState(true)]
public bool? AProperty { get; set; }
[RadCheckBoxThreeState(false)]
public ToggleState BProperty { get; set; }

Figure 10: RadCheckBoxThreeStateAttribute

WinForms RadPropertyGrid RadCheckBoxThreeStateAttribute

TypeConverterAttribute

The TypeConverterAttribute specifies what type to use as a converter for the object this attribute is bound to.

PropertyStoreItem Item1 = new PropertyStoreItem(typeof(string), "BorderType", "Flat");
Item1.Attributes.Add(new TypeConverterAttribute(typeof(My_TypeConverter)));
store.Add(Item1);
radPropertyGrid1.SelectedObject = store;