/// <summary> /// Updates prefix, postfix and textBox positions /// </summary> private void UpdateLayout() { try { // Size of postfix and prefix in pixels _prefixSize = TextRenderer.MeasureText(_prefix, this.Font); _postfixSize = TextRenderer.MeasureText(_postfix, this.Font); // Prefix // Prefix is not empty string if (_prefix != "") { // Prefix area rectangle _prefixRectangle = new Rectangle(new Point(0, 0), new Size(DIP.ToInt(10) + _prefixSize.Width, this.Height)); _textBox.DrawLeftBorder = false; } else { // Empty area _prefixRectangle = new Rectangle(new Point(0, 0), new Size(0, 0)); _textBox.DrawLeftBorder = true; } // Adjust textBox size _textBox.Size = new Size(this.Width - _prefixRectangle.Width - _postfixRectangle.Width, this.Height); _textBox.Location = new Point(_prefixRectangle.X + _prefixRectangle.Width, 0); // Postfix // Postfix is not empty string if (_postfix != "") { // Postfix area rectangle _postfixRectangle = new Rectangle(new Point(_prefixRectangle.X + _prefixRectangle.Width + _textBox.Width, 0), new Size(DIP.ToInt(10) + _postfixSize.Width, this.Height)); _textBox.DrawRightBorder = false; } else { // Empty area _postfixRectangle = new Rectangle(new Point(0, 0), new Size(0, 0)); _textBox.DrawRightBorder = true; } // Adjust textBox size _textBox.Size = new Size(this.Width - _prefixRectangle.Width - _postfixRectangle.Width, this.Height); _textBox.Location = new Point(_prefixRectangle.X + _prefixRectangle.Width, 0); // Redraw Invalidate(); } catch { } }