7 Replies - 8769 Views - Last Post: 29 June 2011 - 12:53 PM Rate Topic: -----

#1 deery5000  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 966
  • Joined: 09-May 09

Multiline label ?

Posted 29 June 2011 - 05:45 AM

Hi guys,

ive been searching google to find a way of creating a multiline label.

I have seen many times "vbCrLf" being used to create a new line but this wont work the way it want it too.

i have a string of words (appox 100) that changes on a click. i cant see a good method other than inserting "vbCrLf"
at different positions. This isnt really effective.

is there other methods rather than + vbCrLf +

kevin

Is This A Good Question/Topic? 0
  • +

Replies To: Multiline label ?

#2 Nightfish  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 74
  • View blog
  • Posts: 158
  • Joined: 24-May 11

Re: Multiline label ?

Posted 29 June 2011 - 06:05 AM

I don't know anything easier for labels than what you already found. The closest I can get if you don't want to manually handle your linebreaks is a TextBox with "Multiline" and "ReadOnly" set to "true". There probably is a way to make it unclickable too.

This post has been edited by Nightfish: 29 June 2011 - 06:08 AM

Was This Post Helpful? 0
  • +
  • -

#3 deery5000  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 966
  • Joined: 09-May 09

Re: Multiline label ?

Posted 29 June 2011 - 07:24 AM

Thanks anyway.

Its a shame because i want the background of the label to be transparent.
Not sure if i can achieve the same look with the multiline textbox.

Kevin
Was This Post Helpful? 0
  • +
  • -

#4 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1052
  • View blog
  • Posts: 4,077
  • Joined: 02-July 08

Re: Multiline label ?

Posted 29 June 2011 - 08:25 AM

You could use GDI+ and draw the string using StringFormat as a an aid to the format if needed. All you do is define a rectangle and draw the text inside it, no transparency to worry about.

This post has been edited by hawkvalley1: 29 June 2011 - 08:52 AM

Was This Post Helpful? 1
  • +
  • -

#5 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1052
  • View blog
  • Posts: 4,077
  • Joined: 02-July 08

Re: Multiline label ?

Posted 29 June 2011 - 08:49 AM

Opps my phone its double posting.

This post has been edited by hawkvalley1: 29 June 2011 - 08:50 AM

Was This Post Helpful? 0
  • +
  • -

#6 Psyguy  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 71
  • View blog
  • Posts: 320
  • Joined: 12-January 11

Re: Multiline label ?

Posted 29 June 2011 - 08:55 AM

You could use the stringbuilder class. I find it very helpful when trying to concatonate many different strings over multiple lines.

Edit for example:
Dim sb as new Stringbuilder

sb.append("Some text")
sb.appendline(" ,some more text")
sb.appendline(" ,and lastly, even more text.")

mylabel.text=sb.tostring


This post has been edited by Psyguy: 29 June 2011 - 08:57 AM

Was This Post Helpful? 0
  • +
  • -

#7 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,505
  • Joined: 16-March 11

Re: Multiline label ?

Posted 29 June 2011 - 11:41 AM

View PostPsyguy, on 29 June 2011 - 08:55 AM, said:

You could use the stringbuilder class. I find it very helpful when trying to concatonate many different strings over multiple lines.

Edit for example:
Dim sb as new Stringbuilder

sb.append("Some text")
sb.appendline(" ,some more text")
sb.appendline(" ,and lastly, even more text.")

mylabel.text=sb.tostring



You know you can create your own controls, so why not create a multi line label control? I was considering doing it haha. :)
Was This Post Helpful? 0
  • +
  • -

#8 dbasnett  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 109
  • View blog
  • Posts: 603
  • Joined: 01-October 08

Re: Multiline label ?

Posted 29 June 2011 - 12:53 PM

Something like this

        Dim ipsumA() As String
        ipsumA = New String() {"Lorem", "ipsum", "dolor", "sit", _
                                "amet", "consectetur", "adipisicing", _
                                "elit", "sed", "do", "eiusmod", _
                                "tempor", "incididunt", "ut", "labore", _
                                "et", "dolore", "magna", "aliqua", "Ut", _
                                "enim", "ad", "minim", "veniam", "quis", _
                                "nostrud", "exercitation", "ullamco", _
                                "laboris", "nisi", "ut", "aliquip", "ex", _
                                "ea", "commodo", "consequat", "Duis", "aute", _
                                "irure", "dolor", "in", "reprehenderit", "in", _
                                "voluptate", "velit", "esse", "cillum", "dolore", _
                                "eu", "fugiat", "nulla", "pariatur", "Excepteur", _
                                "sint", "occaecat", "cupidatat", "non", "proident", _
                                "sunt", "in", "culpa", "qui", "officia", "deserunt", _
                                "mollit", "anim", "id", "est", "laborum"}

        Label1.Text = String.Join(Environment.NewLine, ipsumA)




        Dim ipsum As String = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
        'or maybe
        Label1.Text = String.Join(Environment.NewLine, ipsum.Split(New Char() {" "c, ","c}, StringSplitOptions.RemoveEmptyEntries))


This post has been edited by dbasnett: 29 June 2011 - 12:59 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1