■ CheckedComboBoxEdit 클래스에서 열거형 값을 표시하는 방법을 보여준다.
▶ ColorType.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
using System; namespace TestProject { [Flags] public enum ColorType { /// <summary> /// 해당 무 /// </summary> None = 0x00, /// <summary> /// 검정색 /// </summary> Black = 0x01, /// <summary> /// 흰색 /// </summary> White = 0x02, /// <summary> /// 파란색 /// </summary> Blue = 0x04, /// <summary> /// 노란색 /// </summary> Yellow = 0x08, /// <summary> /// 녹색 /// </summary> Green = Blue | Yellow } } |
▶ MainForm.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
using System; using DevExpress.XtraEditors; using DevExpress.XtraEditors.Repository; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : XtraForm { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); this.checkedComboBoxEdit.Properties.SetFlags(typeof(ColorType)); RemoveCombinedFlag(checkedComboBoxEdit.Properties); this.checkedComboBoxEdit.SetEditValue(ColorType.Black | ColorType.Green); } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private #region 결합 플래그 제거하기 - RemoveCombinedFlag(repositoryItemCheckedComboBoxEdit) /// <summary> /// 결합 플래그 제거하기 /// </summary> /// <param name="repositoryItemCheckedComboBoxEdit">저장소 항목 체크 콤보 박스 에디터</param> private void RemoveCombinedFlag(RepositoryItemCheckedComboBoxEdit repositoryItemCheckedComboBoxEdit) { for(int i = repositoryItemCheckedComboBoxEdit.Items.Count - 1; i > 0; i--) { Enum value1 = repositoryItemCheckedComboBoxEdit.Items[i].Value as Enum; for(int j = i - 1; j >= 0; j--) { Enum value2 = repositoryItemCheckedComboBoxEdit.Items[j].Value as Enum; if(value1.HasFlag(value2)) { repositoryItemCheckedComboBoxEdit.Items.RemoveAt(i); break; } } } } #endregion } } |