-
Notifications
You must be signed in to change notification settings - Fork 1
/
UnboundRowHelper.vb
37 lines (30 loc) · 1.47 KB
/
UnboundRowHelper.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
Imports System
Imports System.Collections.Generic
Imports DevExpress.XtraVerticalGrid
Imports DevExpress.XtraVerticalGrid.Events
Imports System.ComponentModel
Imports System.Collections
Namespace DXApplication3
Public Class UnboundRowsHelper
Private ReadOnly _PropertyGrid As PropertyGridControl
Private _UnboundRows As List(Of UnboundRow) = New List(Of UnboundRow)()
Public Sub New(ByVal pg As PropertyGridControl)
_PropertyGrid = pg
AddHandler _PropertyGrid.CustomPropertyDescriptors, AddressOf _PropertyGrid_CustomPropertyDescriptors
End Sub
Private Sub _PropertyGrid_CustomPropertyDescriptors(ByVal sender As Object, ByVal e As CustomPropertyDescriptorsEventArgs)
If TryCast(sender, PropertyGridControl).SelectedObject Is e.Source Then
Dim properties As PropertyDescriptorCollection = e.Properties
Dim list As ArrayList = New ArrayList(properties)
list.AddRange(_UnboundRows)
Dim result As PropertyDescriptor() = New PropertyDescriptor(list.Count - 1) {}
list.ToArray().CopyTo(result, 0)
e.Properties = New PropertyDescriptorCollection(result)
End If
End Sub
Public Sub AddUnboundRow(ByVal fieldName As String, ByVal valueType As Type)
Dim row As UnboundRow = New UnboundRow(fieldName, valueType)
_UnboundRows.Add(row)
End Sub
End Class
End Namespace