Http://www.devexpress.com/Support/Center/e/E689.aspx
Using system;
Using system. Windows. forms;
Using devexpress. xtraeditors;
Using devexpress. expressapp. utils;
Using devexpress. expressapp. model;
Using devexpress. expressapp. editors;
Using devexpress. xtraeditors. repository;
Namespace winsolution. Module. Win {
[Propertyeditor (typeof (system. Enum), true)]
Public class enumpropertyeditorex: devexpress. expressapp. Win. Editors. enumpropertyeditor {
Public enumpropertyeditorex (type objecttype, imodelmemberviewitem Model)
: Base (objecttype, model ){
}
Private bool typehasflagsattribute (){
Return getunderlyingtype (). getcustomattributes (typeof (flagsattrites), true). length> 0;
}
Protected override object createcontrolcore (){
Checkedcomboboxedit checkededit = new checkedcomboboxedit ();
Checkededit. textchanged + = checkededit_textchanged;
If (typehasflagsattribute ())
Return checkededit;
Return base. createcontrolcore ();
}
// Dennis: This code is needed to bypass a binding problem in the xtraeditors (s35490)
Private void checkededit_textchanged (Object sender, eventargs e ){
(Checkedcomboboxedit) sender). refresheditvalue ();
}
Protected override repositoryitem createrepositoryitem (){
If (typehasflagsattribute ())
Return new repositoryitemcheckedcomboboxedit ();
Return base. createrepositoryitem ();
}
Protected override void setuprepositoryitem (repositoryitem ){
Base. setuprepositoryitem (item );
If (typehasflagsattribute ()){
Enumdescriptor descriptor = new enumdescriptor (getunderlyingtype ());
Repositoryitemcheckedcomboboxedit checkeditem = (repositoryitemcheckedcomboboxedit) item );
Checkeditem. beginupdate ();
Checkeditem. Items. Clear ();
Checkeditem. selectallitemvisible = false;
// DENNIS: This is required to show localized items in the editor.
Foreach (object Value in descriptor. values)
Checkeditem. Items. Add (value, descriptor. getcaption (value), checkstate. Unchecked, true );
// DENNIS: use this method if you don't to show localized items in the editor.
// Checkeditem. setflags (getunderlyingtype ());
Checkeditem. endupdate ();
}
}
}
}