/****************************** * 说明:自定义带复选框自动搜索框控件 * 创建人:龚宇超 * 创建日期:2017-08-07 * 修改人: * 修改日期: * 修改备注: * 版本:1.0.0.0 ******************************/ using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using DevExpress.XtraEditors; using Lskj.Control.Model; using Lskj.Business.Impl; namespace Lskj.Control { /// /// 复选框自动搜索框控件 /// public partial class LabelCheckAutoTextEdit : BaseUserControl { /// /// 复选框控件 /// /// The check edit. public CheckEdit CheckEdit { get { return ckCheck; } } /// /// 自动搜索框控件 /// public AutoGridLookUp TextEdit { get { return labelAutoTextEdit1.TextEdit; } } /// /// 自定义下拉搜索框 /// /// The automatic text edit. public LabelAutoTextEdit AutoTextEdit { get { return labelAutoTextEdit1; } } /// /// 点击后清空数据 /// public bool clickAfterEmpty; public LabelCheckAutoTextEdit() { InitializeComponent(); this.TextEdit.Enabled = false; this.TextEdit.Click += new EventHandler(TextEditClick); } private void TextEditClick(object sender, EventArgs e) { if (TextEdit.Enabled&& clickAfterEmpty) { this.AutoTextEdit.EditText = ""; this.TextEdit.ShowPopup(); SendKeys.Send("{Esc}"); //this.TextEdit._popup.EditValue = ""; //TextEdit.Text = ""; } } /// /// 说明:设置控件显示文本 /// 创建人:龚宇超 /// 创建日期:2017-08-07 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// 显示Lebel文本 public override string LabelText { get { return this.AutoTextEdit.LabelText; } set { this.AutoTextEdit.LabelText = value; } } /// /// 控件值 /// /// The edit text. public override string EditText { get { return base.EditText; } set { labelAutoTextEdit1.EditText = value; TextEdit.Enabled = ckCheck.Checked = !string.IsNullOrWhiteSpace(labelAutoTextEdit1.EditText); } } /// /// 只读文本颜色 /// /// The color of the read only label. public override bool ReadOnly { get { return base.ReadOnly; } set { base.ReadOnly = value; this.labelAutoTextEdit1.ReadOnly = value; } } /// /// 必填文本颜色 /// /// The color of the required label. public override bool Required { get { return base.Required; } set { base.Required = value; if (value) { this.labelAutoTextEdit1.Label.ForeColor = base.RequiredLabelForceColor; } } } /// /// 说明:需要单独验证是否修改 /// 创建人:龚宇超 /// 创建日期:2017-11-08 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// true if this instance is update; otherwise, false. public override bool IsUpdate() { if (this.Model.FieldType == ControlType.LabCheckAutoSeacherValue) { return !this.Model.Text.Equals(this.AutoTextEdit.EditValue, StringComparison.OrdinalIgnoreCase); } else { return base.IsUpdate(); } } /// /// 说明:选中改变状态 /// 创建人:龚宇超 /// 创建日期:2017-08-07 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. private void ckCheck_CheckedChanged(object sender, EventArgs e) { try { CheckEdit check = sender as CheckEdit; TextEdit.Enabled = check.Checked; } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); } } /// /// 背景颜色 /// /// The color of the required label. public override Color BackgroundColor { get { return TextEdit.Properties.Appearance.BackColor; } set { TextEdit.Properties.Appearance.BackColor = value; } } /// /// 前景颜色 /// /// The color of the required label. public override Color ForeColor { get { return TextEdit.Properties.Appearance.ForeColor; } set { TextEdit.Properties.Appearance.ForeColor = value; } } /// /// 内容加粗 /// /// The color of the required label. public override bool ContentBold { get { return TextEdit.Properties.Appearance.Font.Bold; } set { Font oldFont = TextEdit.Properties.Appearance.Font; TextEdit.Properties.Appearance.Font = new Font(oldFont.FontFamily, oldFont.Size, value ? FontStyle.Bold : FontStyle.Regular); } } } }