Reputation: 738
How can I change the font size of a TextBox but keep the TextBox height?
At the moment each time I try to change the font size the TextBox height re-sizes based on the font size, I sort of got it to work by changing the TextBox to multiline but only want a single line Textbox.
Upvotes: 2
Views: 25124
Reputation: 112259
In WinForms you can set the MinimumSize
and/or the MaximumSize
properties of the TextBox in order to override the automatic adjustment of the TextBox height, when the font height changes.
Note that setting the minimum and maximum size does not change the TextBox size immediately. But when you change the width of the TextBox in the form designer, its height will be changed to be within the specified limits.
Upvotes: 2
Reputation: 738
The textbox control has a hidden AutoSize property which can be disabled
textBox1.AutoSize = False
textBox1.Height = 50
which I added to foo_load, you do end up with a large box and small font and looks a little odd due to textbox not having any padding property but this can be rectified by putting a panel behind it and positioning the textbox just inside.
Upvotes: 3