Completed
Last Updated: 21 Jun 2018 15:08 by ADMIN
ADMIN
Dess | Tech Support Engineer, Sr.
Created on: 15 Jun 2018 05:18
Category: PropertyGrid
Type: Bug Report
2
FIX. RadPropertyGrid - RadRange attribute is not respected
To reproduce:

Public Class RadForm1
    Sub New()        
        InitializeComponent()
        RadPropertyGrid1.SelectedObject = New MyProperties
    End Sub

    Public Class MyProperties

        Private _height As Integer = 70
        <Browsable(True)> <Category("Rows")> <DisplayName("Height")> _
        <Description("Sets the height of the row. Range 70 to 200.")> _
        <RadRange(70, 200)> _
        Public Property Height() As Integer
            Get
                Return _height
            End Get
            Set(ByVal Value As Integer)
                _height = Value
            End Set
        End Property
    End Class
End Class

When you activate the editor you will notice that you are allowed to enter values outside the specified range 7-200.

Workaround:

AddHandler Me.RadPropertyGrid1.EditorInitialized, AddressOf PropertyGridEditorInitialized

    Private Sub PropertyGridEditorInitialized(sender As Object, e As PropertyGridItemEditorInitializedEventArgs)
        Dim spinEditor As PropertyGridSpinEditor = TryCast(e.Editor, PropertyGridSpinEditor)
        If spinEditor IsNot Nothing Then
            spinEditor.MinValue = 70
            spinEditor.MaxValue = 200
        End If

    End Sub
Attached Files:
(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)
2 comments
ADMIN
Hristo
Posted on: 21 Jun 2018 15:08
Hi Robert,

Thank you for improving the workaround. The has been fixed in the R2 2018 SP release.

Regards,
Hristo
Robert
Posted on: 15 Jun 2018 16:19
The workaround works. But if you have more than one property that uses the RadRange attribute you will need to add a bit more to the solution. Like this:

Private Sub PropertyGridEditorInitialized(sender As Object, e As PropertyGridItemEditorInitializedEventArgs)

     Dim spinEditor As PropertyGridSpinEditor = TryCast(e.Editor, PropertyGridSpinEditor)

        If spinEditor IsNot Nothing Then

              Dim myItem As PropertyGridItem = TryCast(e.Item, PropertyGridItem)

              If myItem IsNot Nothing then

                   For Each atr As Attribute In myItem.Attributes

                            If TypeOf atr Is RadRangeAttribute Then

                                   Dim myRadRangeAttribute As RadRangeAttribute = CType(atr, RadRangeAttribute)

                                   mySpinEditor.MinValue = myRadRangeAttribute.MinValue

                                   mySpinEditor.MaxValue = myRadRangeAttribute.MaxValue

                            End If

                    Next

               End If

        End If

     End Sub