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

Works With Enums

7 Answers 363 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 19 Sep 2011, 05:28 PM
Hello.

How to bind PropertyGrid to object with Enum property  (EF Code first).

Thank's.

7 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 20 Sep 2011, 07:48 AM
Hi Daniel,

Generally, if you bind RadPropertyGrid to an item containing an enum property, the generated filed would be a combo box one, giving you the opportunity to change the enum value. I am sending you a sample project illustrating it. Is that the behavior you require ? 

Greetings,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Daniel
Top achievements
Rank 1
answered on 21 Sep 2011, 12:08 PM
 yes. Thank you Maya.
0
Pavel
Top achievements
Rank 1
answered on 27 Jan 2012, 09:09 AM
How can I display localized text for enum value?
The PropertyGrid of Denis Vuyka supports IValueConverter for the displayed items and it was work.

0
Pavel
Top achievements
Rank 1
answered on 27 Jan 2012, 03:49 PM
I found the solution myself, dig deeper in the source. Need add Description attribute to enum values.
enum LineStyle
    {
        [LocalizeDescription("LineStyle.SOLID")]
        SOLID,
        [LocalizeDescription("LineStyle.DOT")]
        DOT,
        [LocalizeDescription("LineStyle.DASH")]
        DASH,
    }
where
    [AttributeUsage(AttributeTargets.Property  | AttributeTargets.Field)]
    public class LocalizeDescriptionAttribute : DescriptionAttribute
    {
        public LocalizeDescriptionAttribute(string description)
            : base(description)
        {}

        public override string Description
        {
            get
            {
                DescriptionValue = RM.GetString(DescriptionValue); // get localized text
                return base.Description;
            }
        }
    }
0
Intecom
Top achievements
Rank 1
answered on 23 Jun 2015, 03:18 PM

But what if enum is from third-party code and we should display localized text for its value?

I mean it is not possible to modify enum's code.

 

0
Stefan
Telerik team
answered on 26 Jun 2015, 01:01 PM
Hello George,

Since such attributes cannot be added at run-time, I can suggest you take a look at the Binding to an enum with localization article as a possible approach is discussed in it. Note, that in order the proposed IValueConverter to be respected, you need to set the AutoGenerateBindingPaths property of RadPropertyGrid to "False". You can also check the Unbound Mode article for more information.

Hope this helps.

Best Regards,
Stefan
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
Yang
Top achievements
Rank 1
answered on 22 Jul 2015, 03:18 PM
Thanks for the project. It solves my problem very well.
Tags
PropertyGrid
Asked by
Daniel
Top achievements
Rank 1
Answers by
Maya
Telerik team
Daniel
Top achievements
Rank 1
Pavel
Top achievements
Rank 1
Intecom
Top achievements
Rank 1
Stefan
Telerik team
Yang
Top achievements
Rank 1
Share this question
or