Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected override void OnTextChanged(EventArgs e)
- {
- try
- {
- if (!string.IsNullOrEmpty(this.Text))
- {
- int maxLength = InputType == InputTypeEnum.Dec ? 3 : 2;
- if (Text.Length > maxLength)
- {
- StringBuilder removedText = new StringBuilder();
- Text = removedText.Append(this.Text).Remove(maxLength, this.Text.Length - maxLength).ToString();
- }
- if (Convert.ToInt32(this.Text, (int)InputType) > 255)
- Text = InputType == InputTypeEnum.Dec ? "255" : "FF";
- else if (Convert.ToInt32(this.Text, (int)InputType) < 0)
- Text = "00";
- }
- base.OnTextChanged(e);
- }
- catch { this.Text = "0"; }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement