| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
-
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Drawing.Design;
- using System.Reflection;
- using System.Windows.Forms;
- using Dongke.WinForm.Utilities;
- namespace Dongke.WinForm.Controls
- {
- /// <summary>
- /// 查询文本框控件(2个文本框)
- /// </summary>
- [ToolboxBitmap(typeof(ScbSearchBox), "ToolboxBitmap.SearchBox_00.bmp")]
- [DefaultEvent("SelectedItemChanged"), DefaultProperty("SearchText")]
- public partial class ScbSearch2Box : ScbSearchBox
- {
- #region 事件声明
- #endregion
- #region 成员变量
- ///// <summary>
- ///// 为此控件显示的属性
- ///// </summary>
- private string _displayMember2 = string.Empty;
- /// <summary>
- /// 初始化的文本
- /// </summary>
- private string _initText2 = null;
- /// <summary>
- /// 初始化的值
- /// </summary>
- private object _initValue2 = null;
- #endregion
- #region 构造函数
- /// <summary>
- /// 查询文本框控件
- /// </summary>
- private ScbSearch2Box(bool isInitControls = true)
- :base(false)
- {
- InitializeComponent();
- if (isInitControls)
- {
- this.InitQueryControls();
- }
- this.txtCondition2.TextChanged += this.Condition_TextChanged;
- this.txtCondition2.KeyDown += this.Condition_KeyDown;
- }
- #endregion
- #region 属性
- /// <summary>
- /// 获取或设置查询条件2(多选时,不能设置)。
- /// </summary>
- [Description("获取或设置查询条件2(多选时,不能设置)。"), Category("CustomerEx")]
- [DefaultValue("")]
- public string Text2
- {
- get
- {
- return this.txtCondition2.Text;
- }
- set
- {
- if (!this.MultiSelect)
- {
- this.txtCondition2.Text = value;
- }
- }
- }
- /// <summary>
- /// 获取或设置控件的显示的属性
- /// </summary>
- [Description("获取或设置控件的显示的属性。"), Category("CustomerEx")]
- [DefaultValue("")]
- public virtual string DisplayMember2
- {
- get
- {
- return this._displayMember2;
- }
- set
- {
- if (value == null)
- {
- value = string.Empty;
- }
- if (this._displayMember2 != value)
- {
- this._displayMember2 = value;
- this.ResetDisplayText();
- }
- }
- }
- /// <summary>
- /// 获取选择的项目的文本表示形式。
- /// </summary>
- [Description("获取选择的项目的文本表示形式。"), Category("CustomerEx")]
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- public string SearchedText2
- {
- get
- {
- if (this.ValueFrom == SearchBoxValueFrom.InitValue)
- {
- return this._initText2;
- }
- if (this.ValueFrom != SearchBoxValueFrom.SearchForm)
- {
- return null;
- }
- if (this._checkedData == null ||
- this._checkedData.Rows.Count == 0 ||
- !this._checkedData.Columns.Contains(this._displayMember2))
- {
- return null;
- }
- return this.FormatDisplay(this._checkedData.Rows[0][this._displayMember2]);
- }
- }
- /// <summary>
- /// 获取选定的项目的文本表示形式。
- /// </summary>
- [Description("获取选定的项目的文本表示形式。"), Category("CustomerEx")]
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- public string[] CheckedTexts2
- {
- get
- {
- if (this.ValueFrom != SearchBoxValueFrom.SearchForm)
- {
- return null;
- }
- if (this._checkedData == null ||
- this._checkedData.Rows.Count == 0 ||
- !this._checkedData.Columns.Contains(this._displayMember2))
- {
- return null;
- }
- string[] values = new string[this._checkedData.Rows.Count];
- for (int i = 0; i < this._checkedData.Rows.Count; i++)
- {
- values[i] = this.FormatDisplay(this._checkedData.Rows[i][this._displayMember2]);
- }
- return values;
- }
- }
- /// <summary>
- /// 获取选定的项目的文本表示形式,用【,】隔开。
- /// </summary>
- [Description("获取选定的项目的文本表示形式,用【,】隔开。"), Category("CustomerEx")]
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- public string CheckedText2
- {
- get
- {
- if (this.ValueFrom != SearchBoxValueFrom.SearchForm)
- {
- return null;
- }
- string[] values = this.CheckedTexts2;
- if (values == null)
- {
- return string.Empty;
- }
- string value =
- string.Join(Constant.MULTIPLE_TEXT_SEPARATOR,
- values);
- return value;
- }
- }
- #endregion
- #region 重写属性
- #endregion
- #region 事件处理
- #endregion
- #region 公有方法
- /// <summary>
- /// 打开查询窗体
- /// </summary>
- public override void ShowSearchForm()
- {
- if (!this.MultiSelect)
- {
- this.SearchForm.SetConditions(this.txtCondition1.Text, this.txtCondition2.Text);
- }
- this.SearchForm.Show();
- }
- /// <summary>
- /// 初始化显示的值
- /// </summary>
- /// <param name="text"></param>
- /// <param name="value"></param>
- /// <param name="text2"></param>
- /// <param name="value2"></param>
- public virtual void InitValue(string text, object value, string text2, object value2)
- {
- this._initText2 = text2;
- this._initValue2 = value2;
- this.txtCondition2.Text = text2;
- base.InitValue(text, value);
- }
- #endregion
- #region 保护方法
- /// <summary>
- /// 初始化查询文本框集合
- /// </summary>
- protected override void InitQueryControls()
- {
- //base.InitQueryControls();
- this._queryControls.Add(this.txtCondition1);
- this._queryControls.Add(this.txtCondition2);
- }
- /// <summary>
- /// 选择窗体关闭时,设置显示文本。
- /// </summary>
- protected override void ResetDisplayText()
- {
- this._resetText = true;
- this.txtCondition2.Text = this.CheckedText2;
- base.ResetDisplayText();
- }
- /// <summary>
- /// 设置文本框只读
- /// </summary>
- protected override void SetEditReadOnly()
- {
- base.SetEditReadOnly();
- this.txtCondition2.ReadOnly = this.txtCondition1.ReadOnly;
- }
- #endregion
- #region 私有方法
- #endregion
- #region IDataVerifiable 成员
- /// <summary>
- /// 清除输入项
- /// </summary>
- public override void ClearValue()
- {
- //this.txtCondition2.ClearValue();
- base.ClearValue();
- }
- #endregion
- }
- }
|