In my new WinForms project I have a series of 1-digit textboxes, like this:
I would like the digits to fit more snugly in their boxes, with not so much whitespace around them. But I can't get the textbox any smaller, or the font any bigger.
The
I had the same issue with a label (the dot in the Gas reading), but setting the label's
Alas,
The code :
I would like the digits to fit more snugly in their boxes, with not so much whitespace around them. But I can't get the textbox any smaller, or the font any bigger.
The
TextBox
es have zero margin and center text. The font used is Consolas 16pt
. I would like to be able to set the TextBox
size to (20,20) for example, but the designer does not accept anything smaller than(20,32). Not even when I change it manually in Form1.Designer.cs
. I had the same issue with a label (the dot in the Gas reading), but setting the label's
AutoSize
propertry to false fixed that. Alas,
TextBox
does not seem to have this property. Any ideas out there ?The code :
Textbox definitions:
this.textBox1.Font = new System.Drawing.Font("Consolas", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.textBox1.Location = new System.Drawing.Point(12, 358);
this.textBox1.Margin = new System.Windows.Forms.Padding(0);
this.textBox1.MaxLength = 1;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(32, 32);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "0";
this.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;