Showing posts with label tab. Show all posts
Showing posts with label tab. Show all posts

Tuesday, March 24, 2009

Displaying the TAB escape character in a label

The '\t' character is a bit tricky. When you use the tab character, the compiler translates it to this squared character that we have all seen in class. This squared character is correctly interpreted, and displays perfectly in C# console. The only problem is that the tab character does not display properly in controls at form level.

Solution:
To display the escape character for '\t', I made use of the replace function.

private void button_Click(object sender, EventArgs e)
{
string s = "\tDenis\t";
s = s.Replace("\t", " ");
label1.Text = s.ToString();
}