using System; using System.Windows.Forms; namespace UAS_LabelMachine.CustomControl { public partial class SearchTextBox : UserControl { public SearchTextBox() { InitializeComponent(); } private string caller; private string formName; //定义委托 public delegate void OnTextChange(object sender, EventArgs e); //定义事件 public event OnTextChange UserControlTextChanged; //定义委托 public delegate void Icon_Click(object sender, EventArgs e); public event Icon_Click SearchIconClick; private void TextBox_TextChanged(object sender, EventArgs e) { UserControlTextChanged?.Invoke(sender, new EventArgs()); } public override string Text { get { return TextBox.Text; } set { TextBox.Text = value; } } public string Caller { get { return caller; } set { caller = value; } } private string[] setValueField; public string FormName { get { return formName; } set { formName = value; } } private string condition; public string[] SetValueField { get { return setValueField; } set { setValueField = value; } } public string Condition { get { return condition; } set { condition = value; } } public string TableName { get { return tableName; } set { tableName = value; } } public string SelectField { get { return selectField; } set { selectField = value; } } private string tableName; private string selectField; private void Search_Icon_Click(object sender, EventArgs e) { SearchIconClick?.Invoke(sender, new EventArgs()); DbFind db = new DbFind(Name, tableName, selectField, setValueField, caller, formName, condition); if (db.IsAbleDbFind1) { db.ShowDialog(); } else { MessageBox.Show("该字段未配置DbFind", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } private void TextBox_Enter(object sender, EventArgs e) { TextBox.BackColor = System.Drawing.Color.GreenYellow; } private void TextBox_Leave(object sender, EventArgs e) { TextBox.BackColor = System.Drawing.Color.White; } } }