Is it possible to create a third column in a PropertyGrid? For example: PropertyName - PropertyValue - Units of Measure (ie: "Starting Length" - "1000" - "meters" or "Base Pressure" - "22" - "psi")
I'm guessing that I might need to create a custom PropertyGrid control that descends from RadPropertyGrid with the third column, and then maybe a custom PropertyStoreItem that includes a field for the third column value (in this case the units of measure). And then somehow bind it all together.
I am new to Telerik, and do not have any experience with your Telerik Presentation Framework.
Thank you.
I'm guessing that I might need to create a custom PropertyGrid control that descends from RadPropertyGrid with the third column, and then maybe a custom PropertyStoreItem that includes a field for the third column value (in this case the units of measure). And then somehow bind it all together.
I am new to Telerik, and do not have any experience with your Telerik Presentation Framework.
Thank you.
4 Answers, 1 is accepted
0
Hi Sri,
Thank you for your question.
I would like start with clarification that RadPropertyGrid is not designed to support more than two columns out of the box and I am not able to propose а solution for this which will be applicable in your scenario.
Instead I would like to suggest to create a custom CustomPropertyGridItemElement which contains a label that displays a third value. This value cannot be bindable and you should set it manually depending on the name or the type of the item. For example:
Please, refer to the attached sample solution that demonstrates this approach.
I hope this will be applicable for your scenario.
Regards,
Peter
Telerik
Thank you for your question.
I would like start with clarification that RadPropertyGrid is not designed to support more than two columns out of the box and I am not able to propose а solution for this which will be applicable in your scenario.
Instead I would like to suggest to create a custom CustomPropertyGridItemElement which contains a label that displays a third value. This value cannot be bindable and you should set it manually depending on the name or the type of the item. For example:
this
.radPropertyGrid1.CreateItemElement +=
new
CreatePropertyGridItemElementEventHandler(radPropertyGrid1_CreateItemElement);
this
.radPropertyGrid1.EditorInitialized += radPropertyGrid1_EditorInitialized;
this
.radPropertyGrid1.Edited += radPropertyGrid1_Edited;
void
radPropertyGrid1_Edited(
object
sender, PropertyGridItemEditedEventArgs e)
{
RadElement editor = ((PropertyGridTextBoxEditor)(
this
.radPropertyGrid1.ActiveEditor)).EditorElement;
editor.MaxSize =
new
Size(0,0);
}
void
radPropertyGrid1_EditorInitialized(
object
sender, PropertyGridItemEditorInitializedEventArgs e)
{
RadElement editor = ((PropertyGridTextBoxEditor)(
this
.radPropertyGrid1.ActiveEditor)).EditorElement;
editor.MaxSize =
new
Size(editor.Size.Width - 25, editor.Size.Height);
editor.Alignment = System.Drawing.ContentAlignment.MiddleLeft;
}
class
CustomPropertyGridItemElement : PropertyGridItemElement
{
RadLabelElement label;
protected
override
void
CreateChildElements()
{
base
.CreateChildElements();
this
.label =
new
RadLabelElement();
this
.label.Text =
""
;
this
.label.StretchHorizontally =
false
;
this
.label.Margin =
new
Padding(0, 2, 0, 2);
this
.label.Alignment = System.Drawing.ContentAlignment.MiddleRight;
this
.Children.Add(
this
.label);
}
public
override
void
Synchronize()
{
base
.Synchronize();
//check this
//if (((Telerik.WinControls.UI.PropertyGridItem)(((Telerik.WinControls.UI.PropertyGridItemElement)(this)).Data)).Accessor).PropertyType == typeof(string))
if
(
this
.TextElement.Text ==
"CommonText"
)
this
.label.Text =
"kg"
;
else
this
.label.Text =
"ml"
;
}
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(PropertyGridItemElement);
}
}
}
Please, refer to the attached sample solution that demonstrates this approach.
I hope this will be applicable for your scenario.
Regards,
Peter
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
0

Guillaume
Top achievements
Rank 1
answered on 02 Aug 2016, 08:21 PM
Hi there,
Just want to know if it's now possible to add a third column?
I want to show some kind of history like this:
Propertydefinitions | Old values (with nested properties) | New values (with nested properties)
Thanks
0
Hello Guillaume,
Thank you for writing.
RadPropertyGrid is not designed to support three or more columns. Hence, in order to add some additional information, the possible solution is to create a custom PropertyGridItemElement. A sample approach is demonstrated in Peter's reply. Feel free to modify it in a way which suits your requirement best.
The following help article demonstrates a approach as well: http://docs.telerik.com/devtools/winforms/propertygrid/custom-items
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Telerik by Progress
Thank you for writing.
RadPropertyGrid is not designed to support three or more columns. Hence, in order to add some additional information, the possible solution is to create a custom PropertyGridItemElement. A sample approach is demonstrated in Peter's reply. Feel free to modify it in a way which suits your requirement best.
The following help article demonstrates a approach as well: http://docs.telerik.com/devtools/winforms/propertygrid/custom-items
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0

Guillaume
Top achievements
Rank 1
answered on 03 Aug 2016, 01:55 PM
Hello Dess,
Thank you for your reply. I'll use the GridView instead, it should be easier and more stable than to tweak the PropertyGrid particularly when I don't really need the other functionalities :)
Thanks again!