■ ListBoxControl 클래스에서 포커스 사각형을 숨기는 방법을 보여준다.
▶ CustomListBoxItemPainter.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 |
using DevExpress.XtraEditors.Drawing; namespace TestProject { /// <summary> /// 커스텀 리스트 박스 항목 페인터 /// </summary> public class CustomListBoxItemPainter : ListBoxItemPainter { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - CustomListBoxItemPainter() /// <summary> /// 생성자 /// </summary> public CustomListBoxItemPainter() : base() { } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Protected #region 항목 BAR 그리기 - DrawItemBar(e) /// <summary> /// 항목 BAR 그리기 /// </summary> /// <param name="e">이벤트 인자</param> protected override void DrawItemBar(ListBoxItemObjectInfoArgs e) { e.PaintAppearance.FillRectangle(e.Cache, e.Bounds); } #endregion } } |
▶ CustomListBoxSkinItemPainter.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 |
using DevExpress.XtraEditors.Drawing; namespace TestProject { /// <summary> /// 커스텀 리스트 박스 스킨 항목 페인터 /// </summary> public class CustomListBoxSkinItemPainter : ListBoxSkinItemPainter { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - CustomListBoxSkinItemPainter() /// <summary> /// 생성자 /// </summary> public CustomListBoxSkinItemPainter() : base() { } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Protected #region 항목 BAR 그리기 - DrawItemBar(e) /// <summary> /// 항목 BAR 그리기 /// </summary> /// <param name="e">이벤트 인자</param> protected override void DrawItemBar(ListBoxItemObjectInfoArgs e) { DrawItemBarCore(e); } #endregion } } |
▶ CustomListBoxViewInfo.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 |
using DevExpress.XtraEditors; using DevExpress.XtraEditors.Drawing; using DevExpress.XtraEditors.ViewInfo; namespace TestProject { /// <summary> /// 커스텀 리스트 박스 뷰 정보 /// </summary> public class CustomListBoxViewInfo : BaseListBoxViewInfo { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - CustomListBoxViewInfo(owner) /// <summary> /// 생성자 /// </summary> /// <param name="owner">소유자</param> public CustomListBoxViewInfo(BaseListBoxControl owner) : base(owner) { } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Protected #region 항목 페인터 생성하기 - CreateItemPainter() /// <summary> /// 항목 페인터 생성하기 /// </summary> /// <returns>항목 페인터</returns> protected override BaseListBoxItemPainter CreateItemPainter() { if(IsSkinnedHighlightingEnabled) { return new CustomListBoxSkinItemPainter(); } return new CustomListBoxItemPainter(); } #endregion } } |
▶ CustomListBoxControl.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; using DevExpress.XtraEditors.ViewInfo; namespace TestProject { /// <summary> /// 커스텀 리스트 박스 컨트롤 /// </summary> public class CustomListBoxControl : ListBoxControl { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - CustomListBoxControl() /// <summary> /// 생성자 /// </summary> public CustomListBoxControl() : base() { } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Protected #region 뷰 정보 생성하기 - CreateViewInfo() /// <summary> /// 뷰 정보 생성하기 /// </summary> /// <returns>기본 스타일 컨트롤 뷰 정보</returns> protected override BaseStyleControlViewInfo CreateViewInfo() { CustomListBoxViewInfo customListBoxViewInfo = new CustomListBoxViewInfo(this); return customListBoxViewInfo; } #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 |
using System.Windows.Forms; using DevExpress.XtraEditors; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : XtraForm { //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); this.listBoxControl1.SelectionMode = SelectionMode.MultiExtended; for(int i = 0; i < 100; i++) { this.listBoxControl1.Items.Add("항목 " + i.ToString()); } this.listBoxControl2.SelectionMode = SelectionMode.MultiExtended; for(int i = 0; i < 100; i++) { this.listBoxControl2.Items.Add("항목 " + i.ToString()); } } #endregion } } |