Last Updated: 30 Mar 2016 10:09 by ADMIN
Dess | Tech Support Engineer, Principal
Created on: 14 Sep 2015 06:35
Category: PropertyGrid
Type: Bug Report
FIX. RadPropertyGrid - properties order is not constant when expanding/collapsing a category group
To reproduce: Use the following code snippet and perform the step illustrating on the attached gif file. Note that this undesired behavior appears randomly.
Partial Public Class Form1
Inherits Telerik.WinControls.UI.RadForm

    Public Sub New()
        radPropertyGrid1.PropertySort = Windows.Forms.PropertySort.Categorized
        radPropertyGrid1.SortOrder = Windows.Forms.SortOrder.None
        Dim metaDocItem As New PropertyStoreItem(GetType(String), "Document ID", "16.0", "Document ID Number", "Meta Data", True)
        Dim fileInfoItem As New PropertyStoreItem(GetType(FileInfo), "File Info", New FileInfo("sample file path", "file name path"), _
                                                  "", "Meta Data", True)
        fileInfoItem.Attributes.Add(New TypeConverterAttribute(GetType(MyDataConverter)))
        Dim stringItem As New PropertyStoreItem(GetType(String), "String", "telerik", "Property storing a string value", "Meta Data", True)
        Dim dockItem As New PropertyStoreItem(GetType(DockStyle), "Dock", DockStyle.Top, "Property containing DockStyle value", "Meta Data", True)

        Dim store As New RadPropertyStore
        Me.RadPropertyGrid1.SelectedObject = store
    End Sub
End Class
Public Class FileInfo
    Private _filePath As String
    Private _fileName As String

    Public Sub New(filePath As String, fileName As String)
        Me._filePath = filePath
        Me._fileName = fileName
    End Sub

    Public ReadOnly Property FilePath() As String
            Return _filePath
        End Get
    End Property

    Public ReadOnly Property FileName() As String
            Return _fileName
        End Get
    End Property
End Class

Public Class MyDataConverter
Inherits ExpandableObjectConverter
    Public Overrides Function CanConvertTo(context As ITypeDescriptorContext, destinationType As Type) As Boolean
        If destinationType = GetType(String) Then
            Return True
        End If
        Return MyBase.CanConvertTo(context, destinationType)
    End Function
    Public Overrides Function ConvertTo(context As ITypeDescriptorContext, culture As System.Globalization.CultureInfo, _
                                        value As Object, destinationType As Type) As Object
        If destinationType <> GetType(String) Then
            Return MyBase.ConvertTo(context, culture, value, destinationType)
        End If
        Return String.Empty
    End Function 
End Class

Workaround: add a RadSortOrderAttribute to each PropertyStoreItem and leave the default  SortOrder = Windows.Forms.SortOrder.Ascending
Attached Files: