Edit this page

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

propertygrid-attributes 001

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

propertygrid-attributes 001

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

propertygrid-attributes 002

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

propertygrid-attributes 003

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

propertygrid-attributes 004

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

propertygrid-attributes 005

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

propertygrid-attributes 006

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

propertygrid-attributes 007

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

propertygrid-attributes 008

See Also