Hi, I am having a small stupid issue and I was hoping you guys could join in with your experience.
I need a textbox with the following (dynamic) data:
TEXT
TEXT
TEXT
TEXT
_______________________
Name: Amount:
Blah 3
Blahblah 10
_______________________
But the text inside the box is the issue.
So far I am making all this text with a StringBuilder
called SB
and in the end I set MyTextBox.Text
= SB.ToString()
;
I set the header inside the box like this:
SB.AppendLine("Name\t\Amount:");
I generate the data inside a loop like this:
SB.AppendLine(name + "\t\t" + amount);
But it doesn't align neatly like my example! If the name is longer than the previous name, the amount will be appear a whole different place on the line - compared to the previous.
Fx. like this:
TEXT
TEXT
TEXT
TEXT
__________________
Navn Antal:
SpecSaver 1
MadEyes 1
Gucci 1
__________________
My first problem: How can I prevent this? What do you usually do when you need a multiline textbox to contain a lot of data. My second problem: When I export it to a .txt document like this:
using(var text = new StreamWriter("textfile.txt", false))
{
text.Write(SB);
}
It gives yet another version of the data, completely misaligned. It should be identical to the MyTextBox.Text.