SearchControl에 값을 입력하여 CheckedListBoxControl 항목을 필터링 할 수 있습니다.

 

	public partial class Form1 : Form
	{
		#region Form1()

		/// <summary>
		/// 생성자 입니다.
		/// </summary>
		public Form1()
		{
			InitializeComponent();

			List<Sample> item = new List<Sample>();

			for (int i = 0; i < 5; i++)
			{
				item.Add(new Sample()
				{
					Name = "Sample" + i.ToString()
				});
			}

			this.checkedListBoxControl1.DataSource    = item;
			this.checkedListBoxControl1.DisplayMember = "Name";
			this.checkedListBoxControl1.CheckMember   = "Check";

			CreateSearchControl();
			
		}

		#endregion

		#region CreateSearchControl()

		/// <summary>
		/// SearchControl을 생성합니다.
		/// </summary>
		private void CreateSearchControl()
		{ 
			this.searchControl1.Client	 = this.checkedListBoxControl1;
            this.searchControl1.Name	 = "searchControl1";

            this.searchControl1.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] 
			{
				new DevExpress.XtraEditors.Repository.ClearButton(),
				new DevExpress.XtraEditors.Repository.SearchButton()
			});

            this.searchControl1.Properties.Client = this.checkedListBoxControl1;
            this.searchControl1.Size			  = new System.Drawing.Size(255, 20);
		}
		#endregion
	}

	public class Sample
	{ 
		/// <summary>
		/// 이름 입니다.
		/// </summary>
		public string Name { get; set; }

		/// <summary>
		/// 체크 여부 입니다.
		/// </summary>
		public bool Check { get; set; }

	}

CheckedListBoxControl 에서 전체 선택 및 전체 선택 해제 하기 입니다.

 

	public partial class Form1 : Form
	{
		#region Form1()

		/// <summary>
		/// 생성자 입니다.
		/// </summary>
		public Form1()
		{
			InitializeComponent();

			this.checkedListBoxControl1.Items.Add("Check All");
			this.checkedListBoxControl1.Items.AddRange(new object[] { "가", "나", "다", "라", "마",});

			this.checkedListBoxControl1.ItemCheck += checkedListBoxControl1_ItemCheck;
		}

		#endregion

		#region checkedListBoxControl1_ItemCheck(sender, e)

		/// <summary>
		/// 아이템을 체크할 때 동작합니다.
		/// </summary>
		/// <param name="sender">이벤트 발생자 입니다.</param>
		/// <param name="e">이벤트 인자 입니다.</param>
		private void checkedListBoxControl1_ItemCheck(object sender, DevExpress.XtraEditors.Controls.ItemCheckEventArgs e)
		{
			if (e.Index == 0)
			{
				if (e.State == CheckState.Checked)
				{
					this.checkedListBoxControl1.CheckAll();
					this.checkedListBoxControl1.Items[0].Description = "UnCheckAll";
				}
				else
				{
					this.checkedListBoxControl1.UnCheckAll();
					this.checkedListBoxControl1.Items[0].Description = "CheckAll";
				}
			}
		}
		#endregion
	}

+ Recent posts