WPF C# - Bind Enum to ComboBox but don't use all enum values -


मान लें कि मेरे पास एक एन्यूम है जिसमें गुण हैं:

  सार्वजनिक enum MyEnum {हां , नहीं, कोई नहीं}  

मैं इन मानों को कॉम्बो बॉक्स में बहुत आसानी से बाँध सकता हूं। हालांकि, मान लीजिए कि मैं "कोई नहीं" मान को छोड़ना चाहता हूं - इस बारे में जाने का सबसे अच्छा तरीका क्या है?

"post-text" itemprop = "text"> < P> आप उपयोग कर सकते हैं और फिर कास्ट को एक IEnumerable प्राप्त करने के लिए, फिर उन लोगों के आधार पर परिणामों को फ़िल्टर कर सकते हैं जिन्हें आप रद्द करना चाहते हैं, उदा:

 < कोड> var आइटम = Enum.GetValues ​​(typeof (MyEnum)) कास्ट & lt; MyEnum & gt; ()। जहां (ई = & gt; ई! = MyEnum.None);  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

c++ - Qt-how to convert a QByteArray to struct -

c# - How to know the number of Threads created and limit the Tasks accordingly -