i'm constructing a TextBox
at runtime:
edit = new TextBox();
this.Controls.Add(edit);
edit.BorderStyle = System.Windows.Forms.BorderStyle.None;
Sometime later i set the location (Location
, Left
/Top
) of the edit box:
edit.Location = new Point(newX, newY);
Problem is that before i adjust the text box's location its Height
is 20 px. e.g.:
edit.Height 20
But as soon as i change the Location
, the text box's height changes to 13 px, e.g.:
edit.Height 13
The problem, of course, is that my value of newY
is based on the height of the text box. As soon as i adjust the text box's location it then shrinks itself - making my calculated value useless.
What i would like is a way to force a TextBox
to rethink it's height:
Before
newX = (int)Math.Round(2*scaleFactor.Width);
newY = (containerHeight - edit.Height) / 2;
After
edit.RethinkAutoSize();
newX = (int)Math.Round(2*scaleFactor.Width);
newY = (containerHeight - edit.Height) / 2;
How can i tell a textbox to update it's internal sense of it's "proper" height?