Click here to Skip to main content
15,943,233 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:

Can anyone know?

can we change the label size in VB.Net?if yes give me solution.....

1 solution

Dear Friend,

The following code example demonstrates the AutoSize property. To run this example, paste the following code in a form and call the InitializeLabel method from the form's constructor or Load method.

' Declare a label.
Friend WithEvents Label1 As System.Windows.Forms.Label

' Initialize the label.
Private Sub InitializeLabel()
    Me.Label1 = New Label
    Me.Label1.Location = New System.Drawing.Point(10, 10)
    Me.Label1.Name = "Label1"
    Me.Label1.TabIndex = 0

    ' Set the label to a small size, but set the AutoSize property
    ' to true. The label will adjust its length so all the text
    ' is visible, however if the label is wider than the form,
    ' the entire label will not be visible.
    Me.Label1.Size = New System.Drawing.Size(10, 10)
    Me.Label1.AutoSize = True
    Me.Label1.Text = "The text in this label is longer than the set size."

End Sub
Share this answer
sathiyak 20-Feb-12 1:28am    
instead this we also give,autosize property as false we can change that label size....anyway thanks...
Varun Sareen 20-Feb-12 1:56am    
yes :) its good you solved yourself

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900