LabelComboBox.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Infragistics.Win.UltraWinEditors;
  10. using Infragistics.Win;
  11. namespace Core.Mes.Client.Comm.Control
  12. {
  13. public partial class LabelComboBox : UserControl, LabelControlInterface
  14. {
  15. public LabelComboBox()
  16. {
  17. InitializeComponent();
  18. }
  19. [Browsable(true), Category("原始系统控件")]
  20. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  21. public Label Label
  22. {
  23. get
  24. {
  25. return this.label1;
  26. }
  27. }
  28. [Browsable(true), Category("原始系统控件")]
  29. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  30. public UltraComboEditor ComboBox
  31. {
  32. get
  33. {
  34. return this.comboBox1;
  35. }
  36. }
  37. [Browsable(true), Category("原始系统控件")]
  38. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  39. public CheckBox CheckBox
  40. {
  41. get
  42. {
  43. return this.checkBox1;
  44. }
  45. }
  46. [Browsable(true), Category("外观")]
  47. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  48. public string Caption
  49. {
  50. get
  51. {
  52. return this.label1.Text;
  53. }
  54. set
  55. {
  56. this.label1.Text = value;
  57. }
  58. }
  59. [Browsable(true), Category("外观")]
  60. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  61. public bool CheckBoxVisible
  62. {
  63. get { return this.checkBox1.Visible; }
  64. set
  65. {
  66. this.checkBox1.Visible = value;
  67. }
  68. }
  69. [Browsable(true), Category("外观")]
  70. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  71. public bool Checked
  72. {
  73. get { return this.checkBox1.Checked; }
  74. set
  75. {
  76. this.checkBox1.Checked = value;
  77. //this.comboBox1.Enabled = checkBox1.Checked;
  78. }
  79. }
  80. [Browsable(true), Category("外观")]
  81. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  82. public bool ComboBoxEnabled
  83. {
  84. get { return this.comboBox1.Enabled; }
  85. set { this.comboBox1.Enabled = value; }
  86. }
  87. [Browsable(false)]
  88. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  89. public object SelecteValue
  90. {
  91. get
  92. {
  93. return this.comboBox1.SelectedItem == null ? "" : this.comboBox1.SelectedItem.DataValue;
  94. }
  95. set
  96. {
  97. this.comboBox1.Value = value;
  98. }
  99. }
  100. [Browsable(false)]
  101. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  102. public override string Text
  103. {
  104. get
  105. {
  106. return this.comboBox1.Text;
  107. }
  108. set
  109. {
  110. this.comboBox1.Text = value;
  111. }
  112. }
  113. [Browsable(true), Category("外观")]
  114. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  115. public DropDownStyle ComboBoxStyle
  116. {
  117. get { return this.comboBox1.DropDownStyle; }
  118. set { this.comboBox1.DropDownStyle = value; }
  119. }
  120. private void checkBox1_VisibleChanged(object sender, EventArgs e)
  121. {
  122. if (checkBox1.Visible == false)
  123. {
  124. label1.Location = checkBox1.Location;
  125. }
  126. else
  127. {
  128. int x = checkBox1.Location.X + checkBox1.Size.Width + 2;
  129. label1.Location = new Point(x, checkBox1.Location.Y);
  130. }
  131. }
  132. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  133. {
  134. this.comboBox1.Enabled = checkBox1.Checked;
  135. }
  136. private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
  137. {
  138. //try
  139. //{
  140. // if (comboBox1.Focused)
  141. // {
  142. // if (comboBox1.DataSource is DataTable)
  143. // {
  144. // DataTable dt = (DataTable)comboBox1.DataSource;
  145. // //dt.DefaultView.RowFilter = comboBox1.DisplayMember + " LIKE '%" + comboBox1.Text.Trim() + "%'";
  146. // }
  147. // comboBox1.DroppedDown = false;
  148. // comboBox1.DropDown();
  149. // }
  150. //}
  151. //catch{};
  152. if (DataBindings["SelecteValue"] != null)
  153. {
  154. DataBindings["SelecteValue"].WriteValue();
  155. }
  156. if (DataBindings["Text"] != null)
  157. {
  158. DataBindings["Text"].WriteValue();
  159. }
  160. }
  161. private void comboBox1_TextChanged(object sender, EventArgs e)
  162. {
  163. }
  164. private void label1_MouseClick(object sender, MouseEventArgs e)
  165. {
  166. if (this.checkBox1.Visible == true)
  167. {
  168. this.checkBox1.Checked = !checkBox1.Checked;
  169. }
  170. }
  171. }
  172. }