-
Notifications
You must be signed in to change notification settings - Fork 1
/
UnboundRowHelper.cs
47 lines (39 loc) · 1.46 KB
/
UnboundRowHelper.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.XtraVerticalGrid;
using DevExpress.XtraVerticalGrid.Events;
using System.ComponentModel;
using System.Collections;
using DevExpress.XtraVerticalGrid.Rows;
namespace DXApplication3
{
public class UnboundRowsHelper
{
private readonly PropertyGridControl _PropertyGrid;
private List<UnboundRow> _UnboundRows = new List<UnboundRow>();
public UnboundRowsHelper(PropertyGridControl pg)
{
_PropertyGrid = pg;
_PropertyGrid.CustomPropertyDescriptors += _PropertyGrid_CustomPropertyDescriptors;
}
void _PropertyGrid_CustomPropertyDescriptors(object sender, CustomPropertyDescriptorsEventArgs e)
{
if ((sender as PropertyGridControl).SelectedObject == e.Source)
{
PropertyDescriptorCollection properties = e.Properties;
ArrayList list = new ArrayList(properties);
list.AddRange(_UnboundRows);
PropertyDescriptor[] result = new PropertyDescriptor[list.Count];
list.ToArray().CopyTo(result, 0);
e.Properties = new PropertyDescriptorCollection(result);
}
}
public void AddUnboundRow(string fieldName, Type valueType)
{
UnboundRow row = new UnboundRow(fieldName, valueType);
_UnboundRows.Add(row);
}
}
}