How do I change the height of a textbox ?
Neither of the below work:
this.TextBox1.Size = new System.Drawing.Size(173, 100);
or
this.TextBox1.Size.Height = 100;
I wanted to be able to change the single line text box height to fit a font size on it without using multi-line if possible.
AutoSize, Minimum, Maximum does not give flexibility. Use multiline and handle the enter key event and suppress the keypress. Works great.
Steps:
I know this is a kind of old post, but I found myself in this same issue, and by investigating a bit I found out that the Height of a WinForms TextBox is actually calculated depending on the size of the font it contains, it's just not quite equal to it.
This guy explains how the calculation is done, and how you can set it on your TextBox to get the desired Height.
Cheers!
There are two ways to do this :
I believe it is the only ways to do it; the bigger font size should automatically fit with the textbox
Try the following :)
I think this should work.