Using strings in textboxes and listboxes in C#

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

why does the \t (tab character) not work in a textbox or listbox, but does
work in a MessageBox?
Example: string strText = "ABCD\tEFG";
textBox1.Text = strText;
the above displays as a black grahic, any help??
 
Hi spribob,

\t works as expected in TextBox or ListBox (note that if you set text in the designer \t will be translated to \\t).
I am not sure why you see black graphic and would consider reinstalling .Net if you keep having this problem.

Btw, what do you mean by the above displays as black graphic? All text is black graphic? In that case, maybe your selection color is the same as the text color and \t or not would make no difference.
 
Morten;

I have a simple form a button and a text box, the code in the button event is:
textBox1.Text = "";
textBox1.Text = "ABCD\tEFGH";

when the button is clicked this appears in the text box ABCDxEFGH the x
denotes a black graphic like a solid rectangle. Sorry for the confusion.
 
I'm not sure why the tab character behaves that way.
Do you get the same behaviour if you use "ABCD\r\nEFGH" or when using a RichTextBox?
You could also try "ABCD" + (char)9 + "EFGH".

I have been unable to find anyone else having a similar problem. Reinstalling .Net may be needed.
 
Back
Top