|
-
Jan 17th, 2007, 04:45 PM
#1
Thread Starter
New Member
add txt to a new line in a label
Hello, I am trying to display log information to the user from the database. It works fine my only problem is that I cannot find a way to control how it looks. I have the log data output to one sting that I put together in a loop. I am only using one label to display it all (about 8 – 15 entries). Is there a way to put a new line into a label filed so I can append the data to a new line? If that makes any sense.
Thanks
-
Jan 17th, 2007, 05:01 PM
#2
Hyperactive Member
Re: add txt to a new line in a label
Try using a textbox with multiline set to true instead of a label, and as you add a new line to the text insert a line feed 'vbcrlf'
-
Jan 17th, 2007, 05:10 PM
#3
Fanatic Member
Re: add txt to a new line in a label
No, don't do that. vbCrLf is outmoded.
You can use a stringbuilder with the AppendLine() function, then send that back to the label like this:
VB Code:
Dim myStringBuilder As New System.Text.StringBuilder
myStringBuilder.AppendLine(string goes here)
Label1.Text = myStringBuilder.ToString()
Warren Ayen
Senior C# Developer
DLS Software Studios ( http://www.dlssoftwarestudios.com/)
I use Microsoft Visual Studio 2005, 2008, working with Visual Basic and Visual C#
Hey! If you like my post, or I solve your issue, please Rate Me!
-
Jan 17th, 2007, 05:29 PM
#4
Thread Starter
New Member
Re: add txt to a new line in a label
Thank you both for your help. I would perfer to use the second method but it soesnt seem to put the data onto a new line it still shows up like this:
Code to make string
Dim result As New System.Text.StringBuilder
While DataReader.Read()
Result.AppendLine(DataReader("test_data"))
End While
Label.Text = result
Results look like this:
'Successfully Renamed and moved 00007665.jpg to 5-05-072-11 09-Sep-2005.jpg' 'Successfully Renamed and moved 00007665.jpg to 5-05-072-11 09-Sep-2005.jpg' 'Successfully Renamed and moved 03vvt2kt.tif to PLA1900.tif' 'Successfully Renamed and moved 03vvt2kt.tif to PLA1900.tif' 'Successfully Renamed and moved 1xpbazcg.tif to EZE860013.tif' 'Successfully Renamed and moved 1xpbazcg.tif to EZE860013.tif' 'Successfully Renamed and moved 2xvuaibv.tif to MSL3078.ti
there should be a new line at each "'Successfully "
Thanks again
-
Jan 17th, 2007, 05:35 PM
#5
Fanatic Member
Re: add txt to a new line in a label
Yes, there should be a new line. My test worked, for me
Make sure the label isn't autosizing.
also, change it to Label.Text = Result.ToString()
Warren Ayen
Senior C# Developer
DLS Software Studios ( http://www.dlssoftwarestudios.com/)
I use Microsoft Visual Studio 2005, 2008, working with Visual Basic and Visual C#
Hey! If you like my post, or I solve your issue, please Rate Me!
-
Jan 17th, 2007, 06:16 PM
#6
Re: add txt to a new line in a label
Actually you can do it with simple string concatenation as well, as long as you aren't working with extremely large strings... and I would use Environment.Newline instead of vbcrlf...
VB Code:
Label1.Text = "This is the first line" & Environment.NewLine & "This is the second line"
-
Jan 18th, 2007, 10:21 AM
#7
Thread Starter
New Member
Re: add txt to a new line in a label
Great... works great thanks for the help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|