assume i have a property named MyProperty of type MyType with namespace address of :
NameSpaceMain.Namespace2.Namespace3. ... .LastNameSpace.MyType
as you know when using nested properties the value of the main property (who owns the nested properties) is shown somehow like this in tyhe propertygrid:
+ MyProperty NameSpaceMain.Namespace2.Namespace3. ... LastNameSpace.MyType
what should i do to just show the last part (MyType) or even some other manual Name as the value of my property in the peopertygrid
thank you in advance for your answer
6 Answers, 1 is accepted
In order to achieve your goal you can override the ToString method of your "MyProperty" class like so:
Please find attached sample project that meets your requirements.
All the best,
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Regarding your answer: how can I make it so that the Header updates if the ToString method content changes?
Basically, in such scenario the parent object needs to listen for a property change in its nested object. I have modified the sample project in a way that demonstrates how this can be achieved.
I hope this helps.
See What's Next in App Development. Register for TelerikNEXT.
Sorry for posting on an old thread. But I'm wondering is there a way to achieve this (just need display constant text) without overriding ToString() method?
It is possible to bind a given PropertyDefinition to a particular property of an object. With such approach, however, the Nested properties will try to resolve their Binding within this particular property. You can take a look at the code snippet below, as an example.
With this setup, the PropertyDefinition's Binding will search for the Country and ID properties within the Country property. So, I suggest you sticking to the approach of overriding the ToString() method.