Skip to content

Commit 26c8616

Browse files
authored
Demo: Process change events in PropertyGrid (#512)
1 parent 3a4ad6f commit 26c8616

File tree

4 files changed

+277
-179
lines changed

4 files changed

+277
-179
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// Copyright SmartFormat Project maintainers and contributors.
3+
// Licensed under the MIT license.
4+
//
5+
6+
using System.Collections.Generic;
7+
using System.ComponentModel;
8+
9+
namespace Demo.Sample_Extensions;
10+
11+
public class InventoryItem {
12+
public string Name { get; set; } = string.Empty;
13+
public decimal Price { get; set; }
14+
public int Count { get; set; }
15+
public List<InventoryItem> Components { get; set; } = [];
16+
public override string ToString() => $"{Name} (Comp: {Components.Count})";
17+
}
18+
19+
public class ItemCollectionWrapper
20+
{
21+
// Use the ExpandableObjectConverter so the PropertyGrid
22+
// shows a '+' sign next to the property to expand it.
23+
[TypeConverter(typeof(ExpandableObjectConverter))]
24+
// Use the Category and Description attributes for better display in the grid
25+
[Category("Products")]
26+
[DisplayName("Items")]
27+
[Browsable(true)]
28+
public List<InventoryItem> Items { get; set; }
29+
30+
public ItemCollectionWrapper(List<InventoryItem> items)
31+
{
32+
Items = items;
33+
}
34+
35+
public override string ToString() => $"{Items.Count} items";
36+
37+
}

0 commit comments

Comments
 (0)