Thanks Hristo, but I'm still confused...
I express better my problem. My actual situation is as follow (code and screenshot)
As you can see I populate and edit all the single values.
What I need is to evolve my actual situation to the one shown in the screenshot of the original post.
I can't find a way to group different answers into a collapsable [+].
01.
public
partial
class
Form1 : Form
02.
{
03.
private
Dictionary<Guid,
string
> Materials;
04.
05.
public
Form1()
06.
{
07.
InitializeComponent();
08.
}
09.
10.
private
void
Form1_Load(
object
sender, EventArgs e)
11.
{
12.
radPropertyGrid1.EditorRequired += RadPropertyGrid1OnEditorRequired;
13.
14.
// Material collection
15.
Materials =
new
Dictionary<Guid,
string
>();
16.
Materials.Add(Guid.Parse(@
"970baebf-abbc-480c-af89-2e9c0dc0abe7"
), @
"Wood"
);
17.
Materials.Add(Guid.Parse(@
"b46c5514-8077-4401-b44f-883cc471e548"
), @
"Stone"
);
18.
Materials.Add(Guid.Parse(@
"d994af65-8185-4dbe-8784-37f52fc26fb6"
), @
"Iron"
);
19.
Materials.Add(Guid.Parse(@
"df5c0f2f-b0eb-416e-b14b-0babc73dfc2b"
), @
"Silver"
);
20.
Materials.Add(Guid.Parse(@
"c9a242fb-43b8-47a0-b482-f44dca24bc47"
), @
"Gold"
);
21.
22.
// Store
23.
RadPropertyStore store =
new
RadPropertyStore();
24.
store.Add(
new
PropertyStoreItem(
typeof
(
string
), @
"All Materials"
,
null
,
"Description"
,
"Material"
,
false
));
25.
store.Add(
new
PropertyStoreItem(
typeof
(
string
), @
"Material Top"
,
null
,
"Description"
,
"Material"
,
false
));
26.
store.Add(
new
PropertyStoreItem(
typeof
(
string
), @
"Material Bottom"
,
null
,
"Description"
,
"Material"
,
false
));
27.
store.Add(
new
PropertyStoreItem(
typeof
(
string
), @
"Material Left"
,
null
,
"Description"
,
"Material"
,
false
));
28.
store.Add(
new
PropertyStoreItem(
typeof
(
string
), @
"Material Right"
,
null
,
"Description"
,
"Material"
,
false
));
29.
30.
radPropertyGrid1.SelectedObject = store;
31.
}
32.
33.
private
void
RadPropertyGrid1OnEditorRequired(
object
sender, PropertyGridEditorRequiredEventArgs e)
34.
{
35.
// Create the editor
36.
var editor =
new
PropertyGridDropDownListEditor();
37.
editor.DropDownStyle = RadDropDownStyle.DropDownList;
38.
var element = editor.EditorElement
as
BaseDropDownListEditorElement;
39.
40.
// Compile the values
41.
foreach
(var material
in
Materials)
42.
{
43.
RadListDataItem dataItem =
new
RadListDataItem();
44.
dataItem.Text = material.Value;
45.
dataItem.Value = material.Key;
46.
element.Items.Add(dataItem);
47.
}
48.
49.
// Add the button
50.
var button =
new
RadButtonElement();
51.
button.Text = @
"..."
;
52.
button.StretchHorizontally =
false
;
53.
element.Children[2].Children.Add(button);
54.
55.
56.
// Select the actual value by text (the guid part is lost outside of the editor)
57.
PropertyGridItem pgi = e.Item
as
PropertyGridItem;
58.
foreach
(var item
in
element.Items)
59.
{
60.
if
(item.Text.Equals(pgi.Value))
61.
{
62.
item.Selected =
true
;
63.
break
;
64.
}
65.
}
66.
e.Editor = editor;
67.
}
68.
}