SearchTextBox.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. using System;
  2. using System.Windows.Forms;
  3. namespace UAS_LabelMachine.CustomControl
  4. {
  5. public partial class SearchTextBox : UserControl
  6. {
  7. public SearchTextBox()
  8. {
  9. InitializeComponent();
  10. }
  11. private string caller;
  12. private string formName;
  13. //定义委托
  14. public delegate void OnTextChange(object sender, EventArgs e);
  15. //定义事件
  16. public event OnTextChange UserControlTextChanged;
  17. //定义委托
  18. public delegate void Icon_Click(object sender, EventArgs e);
  19. public event Icon_Click SearchIconClick;
  20. private void TextBox_TextChanged(object sender, EventArgs e)
  21. {
  22. UserControlTextChanged?.Invoke(sender, new EventArgs());
  23. }
  24. public override string Text
  25. {
  26. get
  27. {
  28. return TextBox.Text;
  29. }
  30. set
  31. {
  32. TextBox.Text = value;
  33. }
  34. }
  35. public string Caller
  36. {
  37. get
  38. {
  39. return caller;
  40. }
  41. set
  42. {
  43. caller = value;
  44. }
  45. }
  46. private string[] setValueField;
  47. public string FormName
  48. {
  49. get
  50. {
  51. return formName;
  52. }
  53. set
  54. {
  55. formName = value;
  56. }
  57. }
  58. private string condition;
  59. public string[] SetValueField
  60. {
  61. get
  62. {
  63. return setValueField;
  64. }
  65. set
  66. {
  67. setValueField = value;
  68. }
  69. }
  70. public string Condition
  71. {
  72. get
  73. {
  74. return condition;
  75. }
  76. set
  77. {
  78. condition = value;
  79. }
  80. }
  81. public string TableName
  82. {
  83. get
  84. {
  85. return tableName;
  86. }
  87. set
  88. {
  89. tableName = value;
  90. }
  91. }
  92. public string SelectField
  93. {
  94. get
  95. {
  96. return selectField;
  97. }
  98. set
  99. {
  100. selectField = value;
  101. }
  102. }
  103. private string tableName;
  104. private string selectField;
  105. private void Search_Icon_Click(object sender, EventArgs e)
  106. {
  107. SearchIconClick?.Invoke(sender, new EventArgs());
  108. DbFind db = new DbFind(Name, tableName, selectField, setValueField, caller, formName, condition);
  109. if (db.IsAbleDbFind1)
  110. {
  111. db.ShowDialog();
  112. }
  113. else
  114. {
  115. MessageBox.Show("该字段未配置DbFind", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  116. }
  117. }
  118. private void TextBox_Enter(object sender, EventArgs e)
  119. {
  120. TextBox.BackColor = System.Drawing.Color.GreenYellow;
  121. }
  122. private void TextBox_Leave(object sender, EventArgs e)
  123. {
  124. TextBox.BackColor = System.Drawing.Color.White;
  125. }
  126. }
  127. }