■ CheckedComboBoxEdit 클래스의 팝업에서 CheckedListBoxControl 객체 참조를 구하는 방법을 보여준다.
▶ 예제 코드 (C#)
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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
using System; using System.Linq; using System.Windows.Forms; using DevExpress.Utils.Win; using DevExpress.XtraEditors; ... private CheckedComboBoxEdit checkedComboBoxEdit; ... this.checkedComboBoxEdit.Popup += checkedComboBoxEdit_Popup; this.checkedComboBoxEdit.Closed += checkedComboBoxEdit_Closed; ... #region 체크 콤보 박스 편집 팝업 처리하기 - checkedComboBoxEdit_Popup(sender, e) /// <summary> /// 체크 콤보 박스 편집 팝업 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void checkedComboBoxEdit_Popup(object sender, EventArgs e) { IPopupControl popupControl = sender as IPopupControl; PopupContainerControl popupContainerControl = popupControl.PopupWindow.Controls.OfType<PopupContainerControl>().FirstOrDefault(); if(popupContainerControl != null) { CheckedListBoxControl checkedListBoxControl = popupContainerControl.Controls[0] as CheckedListBoxControl; checkedListBoxControl.MouseDown += checkedListBoxControl_MouseDown; } } #endregion #region 체크 콤보 박스 편집 팝업 닫는 경우 처리하기 - checkedComboBoxEdit_Closed(sender, e) /// <summary> /// 체크 콤보 박스 편집 팝업 닫는 경우 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void checkedComboBoxEdit_Closed(object sender, ClosedEventArgs e) { IPopupControl popupControl = sender as IPopupControl; PopupContainerControl popupContainerControl = popupControl.PopupWindow.Controls.OfType<PopupContainerControl>().FirstOrDefault(); if(popupContainerControl != null) { CheckedListBoxControl checkedListBoxControl = popupContainerControl.Controls[0] as CheckedListBoxControl; checkedListBoxControl.MouseDown -= checkedListBoxControl_MouseDown; } } #endregion #region 체크 리스트 박스 컨트롤 마우스 DOWN 처리하기 - checkedListBoxControl_MouseDown(sender, e) /// <summary> /// 체크 리스트 박스 컨트롤 마우스 DOWN 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void checkedListBoxControl_MouseDown(object sender, MouseEventArgs e) { CheckedListBoxControl checkedListBoxControl = sender as CheckedListBoxControl; if(e.Button == MouseButtons.Left) { int index = checkedListBoxControl.IndexFromPoint(e.Location); if(index != -1) { MessageBox.Show(checkedListBoxControl.Items[i].Description); } } } #endregion |