Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Setting Wrap text for a label in VB.Net

Setting Wrap text for a label in VB.Net

Scheduled Pinned Locked Moved Visual Basic
csharptutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    venkata lakshmi prasanna
    wrote on last edited by
    #1

    Iam designing a form with labels and Textboxes. The TExt of the label is long. SO I have to set Wrap text for the labels. Please tell me how to set wrap text for a label in VB.NET

    M D 2 Replies Last reply
    0
    • V venkata lakshmi prasanna

      Iam designing a form with labels and Textboxes. The TExt of the label is long. SO I have to set Wrap text for the labels. Please tell me how to set wrap text for a label in VB.NET

      M Offline
      M Offline
      MatrixCoder
      wrote on last edited by
      #2

      This probably isn't the best example, but it's the only thing I could think of:

      Dim StartVar As Integer = 5
      Dim EndVar As Integer = Label1.Text.Length
      Dim Tempstring As String

      While Not StartVar < 5
      Tempstring = Label1.Text.Insert(StartVar, ControlChars.NewLine)
      Label1.Text = Tempstring
      StartVar += 5
      If StartVar >= EndVar Then
      Exit While
      End If
      End While

      This example inserts a new line every 5 characters, and then stops if it runs out of characters. Just replace StartVar with the number of characters you want to have on each line of your label. Hope this helps!


      Trinity: Neo... nobody has ever done this before. Neo: That's why it's going to work.

      1 Reply Last reply
      0
      • V venkata lakshmi prasanna

        Iam designing a form with labels and Textboxes. The TExt of the label is long. SO I have to set Wrap text for the labels. Please tell me how to set wrap text for a label in VB.NET

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        You can turn the AutoSize property off, the set the size of the label yourself. With AutoSize turned off, the label control does automatic word wrap.

        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups