c# - How do I have an enum bound combobox with custom string formatting for enum values? -


In the post, a method for using custom attribute DescriptionAttribute is described as: < / [Details ("really nice")] [really good]], [description ("kina nice")] sortoffinis, [description ("absolutely not good")]

And then, you call the function GetDescription by using the syntax:

  GetDescription & lt; HowNice & gt; (NotNice);  

But this does not really help me When I want to populate a combo box with the values ​​of only one enum, because I can not force GetDescription < Combo box to call / code> .

What do I need to have the following requirements:

  • reading (HowNice) myComboBox The selected item will return the value selected as the value value.
  • The user should see a user-friendly display string, not just the name of the counting values. So instead of looking at " NotNice ", users will see " not good ".
  • Hopefully, the solution will require minimal code changes in existing enumeration.

Obviously, I can apply a new class for every error which I can create and override its ToString () , but this is very much

You can write a typewriter that reads to see the specific resources in your resources. In this way you will get multi-language support for the names of the exhibition without any hassle.

Look at the convert / convert formats of type converter, and use reflection to read the attributes on your enum field . / P>


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -