■ ToolTipController 클래스의 GetActiveObjectInfo 이벤트를 사용해 커스텀 툴팁을 표시하는 방법을 보여준다.
▶ PopupControl.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 |
using DevExpress.XtraEditors; namespace TestProject { /// <summary> /// 팝업 컨트롤 /// </summary> public partial class PopupControl : XtraUserControl { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - PopupControl() /// <summary> /// 생성자 /// </summary> public PopupControl() { InitializeComponent(); } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Public #region 정보 업데이트하기 - UpdateInformation(information) /// <summary> /// 정보 업데이트하기 /// </summary> /// <param name="information">정보</param> public void UpdateInformation(Information information) { this.imageEdit.SvgImage = information.ImageByteArray; this.toggleSwitch.EditValue = information.State; this.memoEdit.EditValue = information.Description; } #endregion } } |
▶ 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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
using DevExpress.XtraTreeList; using DevExpress.XtraEditors; using DevExpress.Utils; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : XtraForm { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Private #region Field /// <summary> /// 팝업 컨트롤 /// </summary> private PopupControl popupControl; #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Property ////////////////////////////////////////////////////////////////////////////////////////// Public #region 팝업 컨트롤 - PopupControl /// <summary> /// 팝업 컨트롤 /// </summary> PopupControl PopupControl { get { if(this.popupControl == null) { this.popupControl = new PopupControl(); } return this.popupControl; } } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); this.toolTipController.GetActiveObjectInfo += toolTipController_GetActiveObjectInfo; this.treeList.DataSource = DataHelper.GetInformationBindingList(10); } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private #region 툴팁 컨트롤러 액티브 객체 정보 구하기 - toolTipController_GetActiveObjectInfo(sender, e) /// <summary> /// 툴팁 컨트롤러 액티브 객체 정보 구하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void toolTipController_GetActiveObjectInfo(object sender, ToolTipControllerGetActiveObjectInfoEventArgs e) { TreeList treeList = e.SelectedControl as TreeList; if(treeList != null) { TreeListHitInfo hitInfo = treeList.CalcHitInfo(e.ControlMousePosition); Information information = (Information)treeList.GetDataRecordByNode(hitInfo.Node); if(hitInfo.HitInfoType == HitInfoType.Cell) { e.Info = new ToolTipControlInfo(); e.Info.Object = $"컬럼={hitInfo.Column.FieldName}, 노드 ID={hitInfo.Node.Id}"; e.Info.FlyoutControl = PopupControl; PopupControl.UpdateInformation(information); } } } #endregion } } |