|
-
Mar 13th, 2007, 05:14 PM
#1
Thread Starter
New Member
MultiLine Textbox Question
I have a simple question. I'm just starting to program in the GUI for C#. My teacher wants us to output data in a multiline textbox, but I can't figure out how to do that.
For example, the program we are doing is calculating grades. The button we are clicking is supposed to output all information in to a textbox in a list format. So:
Name: Jason
Id: 1234
Average: 95
Letter Grade: A
My teacher is telling us that this needs to be in a single string like
Code:
stringVariable = name + "/r/n" +
but I know/hope that there is a better way to do this. Any help would be appreciated. Thanks,
- anti_hero0021
-
Mar 13th, 2007, 05:19 PM
#2
Re: MultiLine Textbox Question
stringVariable = name + System.Environment.Newline;
-
Mar 13th, 2007, 05:20 PM
#3
Re: MultiLine Textbox Question
And that should have been \r\n. Backslashes, I believe.
-
Mar 13th, 2007, 05:21 PM
#4
Thread Starter
New Member
Re: MultiLine Textbox Question
-
Mar 13th, 2007, 05:54 PM
#5
Re: MultiLine Textbox Question
There are numerous ways to put multiline data into a TextBox, e.g.
C# Code:
myTextBox.Text = string.Format("Name: {0}\r\nId: {1}\r\nAverage: {2}\r\nLetter Grade: {3}",
name,
id,
average,
letterGrade);
or:
Code:
myTextBox.Lines = new string[] {"Name: " + name,
"Id: " + id.ToString(),
"Average: " + average.ToString(),
"Letter Grade: " + letterGrade};
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
|