-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.vb
49 lines (37 loc) · 1.7 KB
/
Form1.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Imports System
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
Imports DevExpress.XtraVerticalGrid.Events
Namespace PropertySorting
Public Partial Class Form1
Inherits Form
Private allowCustomSorting As Boolean = False
Public Sub New()
InitializeComponent()
propertyGridControl1.SelectedObject = New CustomClass() With {.Property1 = "one", .Property2 = "two", .Property3 = "three", .Property4 = "four", .Property5 = "five"}
End Sub
Private Sub propertyGridControl1_CustomPropertyDescriptors(ByVal sender As Object, ByVal e As CustomPropertyDescriptorsEventArgs)
If allowCustomSorting AndAlso e.Context.PropertyDescriptor Is Nothing Then
e.Properties = e.Properties.Sort(New String() {"Property5", "Property4", "Property3", "Property2", "Property1"})
End If
End Sub
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
allowCustomSorting = Not allowCustomSorting
propertyGridControl1.OptionsBehavior.PropertySort = If(allowCustomSorting, DevExpress.XtraVerticalGrid.PropertySort.NoSort, DevExpress.XtraVerticalGrid.PropertySort.Alphabetical)
propertyGridControl1.Refresh()
End Sub
End Class
Friend Class CustomClass
<DisplayName("C")>
Public Property Property1 As String
<DisplayName("B")>
Public Property Property2 As String
<DisplayName("A")>
Public Property Property3 As String
<DisplayName("D")>
Public Property Property4 As String
<DisplayName("E")>
Public Property Property5 As String
End Class
End Namespace