CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2009
    Posts
    177

    Wrap Text in vb.net

    I have the following code in my vb.net:

    Code:
     lbl.Text = lbl.Text & "<table width=""100%"" border=""1"" bordercolor=""#111111"" cellpadding=""0"" cellspacing=""1"" style=""border-collapse: collapse"">"
                lbl.Text = lbl.Text & "<tr>"
    lbl.Text = lbl.Text & "<td class=""tableHeader2"" style=""height: 42px; max-width: 4%; text-align: center; FONT-WEIGHT: bold; FONT-SIZE: 8px; COLOR: #000000; FONT-FAMILY: Arial; BACKGROUND-COLOR: #cccccc;"">"
                lbl.Text = lbl.Text & "GRN"
                lbl.Text = lbl.Text & "</td>"
    lbl.text=lbl.text & "</tr>"
    
     lbl.Text = lbl.Text & "<tr>"
                            lbl.Text = lbl.Text & "<td style=""text-align: center;"">" + ShortenDescription(dsDetails.Tables(0).Rows(b).Item("GRNNo").ToString(),5)
                            lbl.Text = lbl.Text & "</td>"
    lbl.text=lbl.text & "</tr>"
    
    
    Public Function ShortenDescription(ByVal str As String, ByVal len As Integer) As String
                If String.IsNullOrEmpty(str) Then
                    Return String.Empty
                ElseIf str.Length > len Then
                    Return String.Format("{0}...", str.Substring(0, len))
                Else
                    Return str
                End If
            End Function
    in the GRNNo, there are around 10 character, but I would like to wrap the text after 5 character. However, although I had create a function to make it wrap, but it will display "12345..." rather than wrap the text.Anyone can teach me how to wrap the text?

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Wrap Text in vb.net

    Why don't you just add an Enter where you want it to be wrapped &#191;

  3. #3
    Join Date
    Jan 2009
    Posts
    177

    Re: Wrap Text in vb.net

    What do you means by add an Enter??

  4. #4
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Wrap Text in vb.net

    Use Environment.Newline or vbCrLf in your ShortenDescription function where you cut the text.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured