123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- namespace UAS_MES_NEW.CustomControl.TextBoxWithIcon
- {
- public partial class TextBoxWithTextArea : UserControl
- {
- bool TextBoxEnable1;
- bool TextAreaEnable1;
- public TextBoxWithTextArea()
- {
- InitializeComponent();
- }
-
- public override string Text
- {
- get
- {
- return TextAreaTextBox.Text;
- }
- set
- {
- TextAreaTextBox.Text = value;
- }
- }
- public bool TextBoxEnable
- {
- get
- {
- return TextBoxEnable1;
- }
- set
- {
- TextBoxEnable1 = value;
- }
- }
- public bool TextAreaEnable
- {
- get
- {
- return TextAreaEnable1;
- }
- set
- {
- TextAreaEnable1 = value;
- }
- }
- private void TextAreaIcon_Click(object sender, EventArgs e)
- {
-
- var screenPoint = PointToScreen(TextAreaIcon.Location);
- bool GetParent = true;
- TextAreaForm taf = new TextAreaForm();
- taf.Controls["TextArea"].Enabled = TextAreaEnable1;
- taf.Controls["Clean"].Enabled = TextAreaEnable1;
-
- string FormName = this.FindForm().Name;
- int i = 0;
-
- Control c = this;
-
- while (GetParent)
- {
- c = c.Parent;
- if (c.Name == FormName)
- {
- GetParent = false;
- }
- i++;
- }
-
- string[] ControlsName = new string[i];
-
- taf.FormName = FormName;
-
- c = this;
-
- for (int j = 0; j < i; j++)
- {
- if (c.Name != FormName)
- {
- ControlsName[j] = c.Name;
- }
- c = c.Parent;
- }
- taf.ControlName = ControlsName;
- taf.X = screenPoint.X / 2;
- taf.Y = screenPoint.Y / 2;
- taf.ShowDialog();
- }
- private void textBox1_Leave(object sender, EventArgs e)
- {
- TextAreaTextBox.BackColor = Color.White;
- }
- private void textBox1_Enter(object sender, EventArgs e)
- {
- TextAreaTextBox.BackColor = Color.GreenYellow;
- }
- private void TextBoxWithTextArea_SizeChanged(object sender, EventArgs e)
- {
- TextAreaTextBox.Width = this.Width - TextAreaIcon.Width - 3;
- }
- private void TextBoxWithTextArea_Load(object sender, EventArgs e)
- {
- TextAreaTextBox.Enabled = TextBoxEnable1;
- }
- }
- }
|