LabelTextBox.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 Core.Mes.Client.Comm.Tool;
  10. namespace Core.Mes.Client.Comm.Control
  11. {
  12. //[DefaultBindingProperty("defualtValue")]
  13. //[DefaultProperty("defualtValue")]
  14. public partial class LabelTextBox : UserControl, LabelControlInterface
  15. {
  16. public LabelTextBox()
  17. {
  18. InitializeComponent();
  19. }
  20. [Browsable(true), Category("原始系统控件")]
  21. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  22. public Label Label
  23. {
  24. get
  25. {
  26. return this.label1;
  27. }
  28. }
  29. [Browsable(true), Category("原始系统控件")]
  30. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  31. public TextBox TextBox
  32. {
  33. get
  34. {
  35. return this.textBox1;
  36. }
  37. }
  38. [Browsable(true), Category("原始系统控件")]
  39. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  40. public CheckBox CheckBox
  41. {
  42. get
  43. {
  44. return this.checkBox1;
  45. }
  46. }
  47. [Browsable(true), Category("外观")]
  48. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  49. public string Caption
  50. {
  51. get
  52. {
  53. return this.label1.Text;
  54. }
  55. set
  56. {
  57. this.label1.Text = value;
  58. }
  59. }
  60. [Browsable(true), Category("外观")]
  61. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  62. //[Bindable(true, BindingDirection.TwoWay)]
  63. public override string Text
  64. {
  65. get
  66. {
  67. return this.textBox1.Text;
  68. }
  69. set
  70. {
  71. this.textBox1.Text = value;
  72. //DataBindings["Text"].WriteValue();
  73. }
  74. }
  75. [Browsable(true), Category("外观")]
  76. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  77. public bool CheckBoxVisible
  78. {
  79. get { return this.checkBox1.Visible; }
  80. set
  81. {
  82. this.checkBox1.Visible = value;
  83. }
  84. }
  85. [Browsable(true), Category("外观")]
  86. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  87. public bool Checked
  88. {
  89. get { return this.checkBox1.Checked; }
  90. set
  91. {
  92. this.checkBox1.Checked = value;
  93. }
  94. }
  95. [Browsable(true), Category("外观")]
  96. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  97. public bool TextBoxEnabled
  98. {
  99. get { return this.textBox1.Enabled; }
  100. set { this.textBox1.Enabled = value; }
  101. }
  102. private void checkBox1_VisibleChanged(object sender, EventArgs e)
  103. {
  104. if (checkBox1.Visible == false)
  105. {
  106. label1.Location = checkBox1.Location;
  107. this.checkBox1.Checked = true;
  108. }
  109. else
  110. {
  111. int x = checkBox1.Location.X + checkBox1.Size.Width + 2;
  112. label1.Location = new Point(x, checkBox1.Location.Y);
  113. }
  114. }
  115. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  116. {
  117. this.textBox1.Enabled = checkBox1.Checked;
  118. }
  119. private void textBox1_TextChanged(object sender, EventArgs e)
  120. {
  121. if (DataBindings["Text"] != null)
  122. {
  123. DataBindings["Text"].WriteValue();
  124. }
  125. }
  126. private void label1_MouseClick(object sender, MouseEventArgs e)
  127. {
  128. if (this.checkBox1.Visible == true)
  129. {
  130. this.checkBox1.Checked = !checkBox1.Checked;
  131. }
  132. }
  133. }
  134. }