Change TextBox font size keeping textBox size (Height) - vb.net

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.

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.

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.

Related

Change only Font Family via FontDialogBox

I'm developing a Windows Form App in VB and I want to create a menu where the user can modify FontStyle and ForeColor of some Labels. This Labels have specific Size according to the GUI.
The idea is to permit the user to change the appearance of the GUI (personalize the font) to be for example more readble. Because of this I need to preserve the ratio between small labels and big labels also in a not absolute precise way (pic)
I'm already using a FontDialog that returns me Color and Font but applying it (obv) change also the size of the font.
This is a portion of my code now:
For Each formLabel As Label In formLabels
formLabel.ForeColor = FontDialog1.Color
formLabel.Font = FontDialog1.Font
Next formLabel
It's possible to change only the FontFamily of a Label (by code)?

How to Stop increasing the size of textbox when another textbox increase its size on report

I am working with Access Report and I have multiple fields in report.
3 of the field (Textbox) is Richtext (Memo field). It handles more than 255 characaters. if the textbox data increase it also increase the hight of the textbox. This behaviour is desireable and it works.
One of field contain the conditional formatting which makes the backcolor 'orange' or 'Red' based on condition.
The Problem it also increase the height of the textbox same as other field.
How can I disable the increasing of the height for that particular textbox?
I remove the field from the stacked Layout and now It is not increasing its size.
post anyother suggestion if its possible without removing the layout.

Change Text Size to Fit Button

I have a bunch of buttons that are populated with multi-lines. Once they are populated I want to change the size of the text so that you can see all the text and none is cut off.
Because the amount of text changes I can't use a set Textsize
How can I tell if the button is showing all the text?

WinForms TableLayoutPanel ComboBox not resizing properly

I'm trying to use a TableLayoutPanel to align a few controls on a form next to their labels like so:
Label1 [combobox ]
LongerLabel [longer combobox]
But when I run the project and grab the right hand side of the form and shrink the form, the combobox doesn't resize, it gets cut off... Now, I were to not use the TableLayoutPanel, but just anchor a combobox to a form's edges, it will resize properly. What am I doing wrong with the TableLayoutPanel?
I found the answer here:
http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.framework.windowsforms.controls/2006-12/msg00209.html
So I set the first column with the label to autosize (I have the label fill docked in the cell and the text alignment set to middle left). Then dock fill the combobox in the second column. Then, set the second column's size type to 100%, NOT autosize. I don't know why it works, but it does.

How to increase the size of a text box base on the text content

I have a report that I need to increase the size of the textbox base on the length of the text. There some formula to calculate the resulting lenght size?
You can either go for a Label with the AutoSize property set to True. Or if you want to stick to TextBox, you can make use of MeasureString method and get the width of the text from there. Use that width to set the width of TextBox.