How to change the size of a textbox in C#
I admit, the title sounds almost trivial. But on the second sight, it is not so easy to change the size of a TextBox control in C#, because a TextBox does not have the AutoSize property. For other controls you can set the AutoSize property to false and then change the height (height-property). For the TextBox control this is unfortunately not the case.
Nevertheless you can set the height of a TextBox by using a small workaround. The trick is as follows:
textBoxTest.Multiline = true;
textBoxTest.MinimumSize = new Size(150, 24);
textBoxTest.Size = new Size(150, 24);
textBoxTest.Multiline = false;
First you have to set the multiline property to true. Then you can adjust, according to your mood, the minimum-size and the size property to change the size of the TextBox. When you’re done, you set the Multiline property back to false. The TextBox maintains the set size just yet. It’s that simple
Who still wonders, why you should […]