[DEVEXPRESS/WINFORM] CheckedListBoxControl 클래스 : GetItemEnabled 이벤트를 사용해 항목 비활성화하기
DevExpress/WinForm 2020. 2. 23. 12:15■ CheckedListBoxControl 클래스 : GetItemEnabled 이벤트를 사용해 항목 비활성화하기
------------------------------------------------------------------------------------------------------------------------
▶ MainForm.cs
using System.Collections.Generic;
using DevExpress.XtraEditors; using DevExpress.XtraEditors.Controls;
namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : XtraForm { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent();
this.checkedListBoxControl.ValueMember = "Name"; this.checkedListBoxControl.DisplayMember = "Name";
this.checkedListBoxControl.DataSource = Employee.GetList();
this.checkedListBoxControl.GetItemEnabled += checkedListBoxControl_GetItemEnabled; }
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private
#region 체크 리스트 박스 컨트롤 항목 이용 가능 여부 구하기 - checkedListBoxControl_GetItemEnabled(sender, e)
/// <summary> /// 체크 리스트 박스 컨트롤 이용 가능 여부 구하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void checkedListBoxControl_GetItemEnabled(object sender, GetItemEnabledEventArgs e) { CheckedListBoxControl checkedListBoxControl = sender as CheckedListBoxControl;
List<Employee> list = checkedListBoxControl.DataSource as List<Employee>;
bool hired = list[e.Index].Hired;
e.Enabled = !hired; }
#endregion } }
|
------------------------------------------------------------------------------------------------------------------------
댓글을 달아 주세요