Textbox Height and text Alignment for four textboxes

Gary Simpson 471 Reputation points
2020-12-24T14:37:13.713+00:00

Hi Great People.

I have 4 textboxes that need to be bigger height than the rest of the textboxes.
How can I manipulate the text to be centre of these 4 textboxes.

I cannot seem to change the Properties on the Textboxes

I have tried using Multiline. but cannot get the result I require. ( Picture Below )

They have to be textboxes because a user has to enter numeric values.

on form Load I have this code...

Imports System.Windows.Forms.VisualStyles  
  
Public Class FrmVAT  
    Private Sub FrmVAT_Load(sender As Object, e As EventArgs) Handles MyBase.Load  
        Me.TextBox1.AutoSize = False  
        Me.TextBox4.Height = 50  
        Me.TextBox4.TextAlign = HorizontalAlignment.Center  
        Me.TextBox4.TextAlign = VerticalAlignment.Center  
  
        Me.TextBox13.AutoSize = False  
        Me.TextBox13.Height = 50  
        Me.TextBox13.TextAlign = HorizontalAlignment.Center  
        Me.TextBox13.TextAlign = VerticalAlignment.Center  
  
        Me.TextBox8.AutoSize = False  
        Me.TextBox8.Height = 50  
        Me.TextBox8.TextAlign = HorizontalAlignment.Center  
        Me.TextBox8.TextAlign = VerticalAlignment.Center  
  
        Me.TextBox17.AutoSize = False  
        Me.TextBox17.Height = 50  
        Me.TextBox17.TextAlign = HorizontalAlignment.Center  
        Me.TextBox17.TextAlign = VerticalAlignment.Center  
    End Sub  

Kind regards
Gary

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,724 questions
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2020-12-24T15:29:27.67+00:00

    Hi Unless you don't want to use a larger font then try setting the font size for those four boxes to a larger size (the TextBoxes will resize to accomodate the larger font) Is that a typo - the first line of posted code where you set TextBox1 (I am supposing it was meant to be TextBox4?) Here is an example using 3 TextBoxes of 6: ![51035-1.png][1] ' FORM1 with 6 ' TextBoxes (1-6) Option Strict On Option Explicit On Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim fs As Single = 16 With TextBox1 .Font = New Font(.Font.FontFamily, fs) .TextAlign = HorizontalAlignment.Center .Text = "TextBox1" End With With TextBox2 .Font = New Font(.Font.FontFamily, fs) .TextAlign = HorizontalAlignment.Center .Text = "TextBox2" End With With TextBox3 .Font = New Font(.Font.FontFamily, fs) .TextAlign = HorizontalAlignment.Center .Text = "TextBox3" End With With TextBox4 .Text = "TextBox4" End With With TextBox5 .Text = "TextBox5" End With With TextBox6 .Text = "TextBox6" End With End Sub End Class [1]: /api/attachments/51035-1.png?platform=QnA


1 additional answer

Sort by: Most helpful
  1. Viorel 117.2K Reputation points
    2020-12-24T15:48:20.903+00:00

    You can remove the border of textbox, insert a Panel control that has a border and BackColor=Window, then place the textbox inside this panel. These operations can be done in Form Designer.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.