using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using ViewComponents.Exeption; namespace ViewComponents { public partial class Input_text : UserControl { public Input_text() { InitializeComponent(); } public event Action ItemChange; public int MinLen { get; set; } = -1; public int MaxLen { get; set; } = -1; public string Element { get { if (MinLen < 0 || MaxLen < 0) return "Range exeption"; if (textBox1.Text.Length < MinLen || textBox1.Text.Length > MaxLen) return "Value exeption"; return textBox1.Text; } set { if (MinLen >= 0 && MaxLen >= 0 && value != null && value.Length >= MinLen && value.Length <= MaxLen) textBox1.Text = value; } } private void textBox1_TextChanged(object sender, EventArgs e) { ItemChange?.Invoke(textBox1.Text); } } }