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; }

<Editor(GetType(PropertyGridBrowseEditor), GetType(BaseInputEditor))> _
Public Property FileLocation() As String
    Get
        Return m_FileLocation
    End Get
    Set(value As String)
        m_FileLocation = value
    End Set
End Property
Private m_FileLocation As String

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; }

<RadRange(1, 5)> _
Public Property DoorsCount() As Byte
    Get
        Return m_DoorsCount
    End Get
    Set(value As Byte)
        m_DoorsCount = value
    End Set
End Property
Private m_DoorsCount As Byte

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; }

<Browsable(False)> _
Public Property MyHiddenProperty() As Integer
    Get
        Return m_MyHiddenProperty
    End Get
    Set(value As Integer)
        m_MyHiddenProperty = value
    End Set
End Property
Private m_MyHiddenProperty As Integer
Public Property MyBrowsableProperty() As Integer
    Get
        Return m_MyBrowsableProperty
    End Get
    Set(value As Integer)
        m_MyBrowsableProperty = value
    End Set
End Property
Private m_MyBrowsableProperty As Integer

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; }

<[ReadOnly](True)> _
Public Property Count() As Integer
    Get
        Return m_Count
    End Get
    Set(value As Integer)
        m_Count = value
    End Set
End Property
Private m_Count As Integer

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; }

<DisplayName("PropertyNameInGerman")> _
Public Property PropertyName() As Double
    Get
        Return m_PropertyName
    End Get
    Set(value As Double)
        m_PropertyName = value
    End Set
End Property
Private m_PropertyName As Double

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; }

<Description("The manufacturer of the item")> _
Public Property Manufacturer() As String
    Get
        Return m_Manufacturer
    End Get
    Set(value As String)
        m_Manufacturer = value
    End Set
End Property
Private m_Manufacturer As String

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; }

Public Property Username() As String
    Get
        Return m_Username
    End Get
    Set(value As String)
        m_Username = value
    End Set
End Property
Private m_Username As String
<PasswordPropertyText(True)> _
Public Property Password() As String
    Get
        Return m_Password
    End Get
    Set(value As String)
        m_Password = value
    End Set
End Property
Private m_Password As String

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; }

<DefaultValue(1.35)> _
Public Property Length() As Decimal
    Get
        Return m_Length
    End Get
    Set(value As Decimal)
        m_Length = value
    End Set
End Property
Private m_Length As Decimal

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; }

<Category("CategoryName")> _
Public Property CategorizedProperty() As String
    Get
        Return m_CategorizedProperty
    End Get
    Set(value As String)
        m_CategorizedProperty = value
    End Set
End Property
Private m_CategorizedProperty As String
Public Property UncategorizedProperty() As String
    Get
        Return m_UncategorizedProperty
    End Get
    Set(value As String)
        m_UncategorizedProperty = value
    End Set
End Property
Private m_UncategorizedProperty As String

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; }

<RadSortOrder(2)> _
Public Property AProperty() As String
    Get
        Return m_AProperty
    End Get
    Set(value As String)
        m_AProperty = value
    End Set
End Property
Private m_AProperty As String
<RadSortOrder(1)> _
Public Property BProperty() As String
    Get
        Return m_BProperty
    End Get
    Set(value As String)
        m_BProperty = value
    End Set
End Property
Private m_BProperty As String
<RadSortOrder(0)> _
Public Property CProperty() As String
    Get
        Return m_CProperty
    End Get
    Set(value As String)
        m_CProperty = value
    End Set
End Property
Private m_CProperty As String

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; }

<RadCheckBoxThreeState(True)>
Public Property AProperty() As Nullable(Of Boolean)
    Get
        Return m_AProperty
    End Get
    Set(value As Nullable(Of Boolean))
        m_AProperty = value
    End Set
End Property
Private m_AProperty As Nullable(Of Boolean)
<RadCheckBoxThreeState(False)>
Public Property BProperty() As ToggleState
    Get
        Return m_BProperty
    End Get
    Set(value As ToggleState)
        m_BProperty = value
    End Set
End Property
Private m_BProperty As ToggleState

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;

Dim store As RadPropertyStore = New RadPropertyStore()
Dim Item1 As PropertyStoreItem = New PropertyStoreItem(GetType(String), "BorderType", "Flat")
Item1.Attributes.Add(New TypeConverterAttribute(GetType(My_TypeConverter)))
store.Add(Item1)
radPropertyGrid1.SelectedObject = store

See Also

In this article