This is a migrated thread and some comments may be shown as answers.

How to handle a List<string> property in the PropertyGrid?

7 Answers 490 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Laurent
Top achievements
Rank 1
Laurent asked on 05 Oct 2015, 05:16 PM

I have a read-only List<string> property in my business object.

How do I make it show up in the property grid. Do I need to create a custom editor?

Thanks!

7 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 06 Oct 2015, 03:00 PM
Hello Laurent,

Please check out the "CollectionEditors" article for a reference. 

Regards,
Maya
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Laurent
Top achievements
Rank 1
answered on 06 Oct 2015, 05:16 PM

CollectionEditor works well for lists of objects with many properties, including one that can be used as a selector.

For simple lists of values or strings, it seems like there is no good solution.

0
Maya
Telerik team
answered on 07 Oct 2015, 07:46 AM
Hello Laurent,

I attached a sample illustrating a case with RadPropertyGrid displaying an item with List<string> property. As you can see, CollectionEditor is its editor. Does this scenario correspond to yours or am I missing anything ? 


Regards,
Maya
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Laurent
Top achievements
Rank 1
answered on 07 Oct 2015, 11:26 PM

Hello Maya,

Yes, your solution works. Please don't take it personally but this is a bad one.You have to click the drop-down button to see the strings, you get a giant panel, two non functional buttons (because readonly) and a right panel that's mostly useless... Here is below what I ended up with: Bind the read-only strings to a custom editor template with just a listbox.

 

<telerik:PropertyDefinition.EditorTemplate
    <DataTemplate>                            
<ListBox 
ItemsSource="{Binding Path=Strings}" />
</DataTemplate>
</telerik:PropertyDefinition.EditorTemplate>‚Äč

0
Maya
Telerik team
answered on 08 Oct 2015, 07:41 AM
Hello Laurent,

Displaying a CollectionEditor for collection properties is the default scenario and its functionality (displaying anything in the field/having enabled/disabled buttons) depends entirely on the type of the source collection.

Still, it is great that found the most appropriate solution for your scenario. Let us know in case you need further assistance with Telerik controls. 


Regards,
Maya
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Dharmavaram
Top achievements
Rank 1
answered on 30 Sep 2016, 06:39 AM

Hi Maya,

I too have similar requirement but I have to store this information back in my property how can I achieve it.how to get the selected item from ListBox and store it in property.

Regards,

Nagasree

0
Yoan
Telerik team
answered on 04 Oct 2016, 02:46 PM
Hello Nagasree,

If you are using the approach with the ListBox in the EditorTemplate, you can bind ListBox's SelectedItem to some your property.

Regards,
Yoan
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
PropertyGrid
Asked by
Laurent
Top achievements
Rank 1
Answers by
Maya
Telerik team
Laurent
Top achievements
Rank 1
Dharmavaram
Top achievements
Rank 1
Yoan
Telerik team
Share this question
or