| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:DKCheckedListBoxComboBox.cs
- * 2.功能描述:下拉列表控件:可以多项选择
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 陈晓野 2014/09/04 1.00 新建
- *******************************************************************************/
- using System;
- using System.ComponentModel;
- using System.Drawing;
- using System.Windows.Forms;
- namespace Dongke.IBOSS.PRD.Basics.BaseControls
- {
- /// <summary>
- /// 下拉列表控件:可以多项选择
- /// </summary>
- public partial class DKCheckedListBoxComboBox : PopupComboBox
- {
- #region 委托声明
- #endregion
- #region 事件声明
- #endregion
- #region 常量
- #endregion
- #region 成员变量
- /// <summary>
- /// 多选控件
- /// </summary>
- private C_CheckedListBoxEx _checkedListBox;
- #endregion
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- public DKCheckedListBoxComboBox() : base()
- {
- InitializeComponent();
- this._checkedListBox = new C_CheckedListBoxEx();
- ListControlContainer containerControl = new ListControlContainer();
- containerControl.Controls.Add(_checkedListBox);
- containerControl.Padding = new Padding(0, 0, 0, 12);
- this._checkedListBox.Dock = DockStyle.Fill;
- this._checkedListBox.IntegralHeight = false;
- this.DropDownControl = containerControl;
- this.dropDown.Resizable = true;
- this._checkedListBox.ItemChecked += CheckedListBox_ItemChecked;
- this.dropDown.Opening += dropDown_Opening;
- }
- #endregion
- #region 单例模式
- #endregion
- #region 属性
-
- /// <summary>
- /// 获取或设置控件的数据源
- /// </summary>
- public new object DataSource
- {
- get
- {
- return this._checkedListBox.DataSource;
- }
- set
- {
- this._checkedListBox.DataSource = value;
- }
- }
- /// <summary>
- /// 获取或设置一个字符串,该字符串指定要显示其内容的列表框中所含对象的属性
- /// </summary>
- public new string DisplayMember
- {
- get
- {
- return this._checkedListBox.DisplayMember;
- }
- set
- {
- this._checkedListBox.DisplayMember = value;
- }
- }
- /// <summary>
- /// 获取或设置一个字符串,该字符串指定要从中取值的数据源的属性
- /// </summary>
- public new string ValueMember
- {
- get
- {
- return this._checkedListBox.ValueMember;
- }
- set
- {
- this._checkedListBox.ValueMember = value;
- }
- }
- /// <summary>
- ///
- /// </summary>
- [Browsable(true)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
- public new CheckedListBox.ObjectCollection Items
- {
- get
- {
- return this._checkedListBox.Items;
- }
- }
- /// <summary>
- ///
- /// </summary>
- [Browsable(true)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
- public C_CheckedListBoxEx CheckedListBox
- {
- get
- {
- return this._checkedListBox;
- }
- }
- public new string Text
- {
- get
- {
- return base.Text;
- }
- }
- #endregion
- #region 事件处理
- private void CheckedListBox_ItemChecked(object sender, ItemCheckEventArgs e)
- {
- base.Text = this._checkedListBox.GetCheckedText();
- }
- private void dropDown_Opening(object sender, CancelEventArgs e)
- {
- this._checkedListBox.ClearSelected();
- }
- #endregion
- #region 公有方法/函数
- #endregion
- #region 受保护方法/函数
- protected override void OnResize(EventArgs e)
- {
- // When the ComboBox is resized, the width of the dropdown
- // is also resized to match the width of the ComboBox. I think it looks better.
- Size Size = new Size(Width, DropDownControl.Height);
- dropDown.Size = Size;
- base.OnResize(e);
- }
- protected override void OnKeyPress(KeyPressEventArgs e)
- {
- base.OnKeyPress(e);
- if (copy)
- {
- copy = false;
- }
- else
- {
- e.Handled = true;
- }
- }
- bool copy = false;
- protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
- {
- if (keyData == (Keys.Control | Keys.C))
- {
- copy = true;
- return base.ProcessCmdKey(ref msg, keyData);
- }
- else
- {
- copy = false;
- return base.ProcessCmdKey(ref msg, keyData);
- }
- }
- #endregion
- #region 私有方法/函数
- #endregion
- }
- }
|