3

I'm trying to insert a tabSpace into a string:

string ab = "a" + "\t" + "b"

But I got a square instead of space. Please help.

3
  • 2
    Did you observe this 'square' on a control's text field? Jun 25, 2012 at 19:13
  • I create a label.Text from this string
    – Buena
    Jun 25, 2012 at 19:16
  • Mark's answer below is the correct one. Jun 25, 2012 at 19:17

1 Answer 1

6

Your code is correct.

Note that there is no need to use string concatenation. This achieves the same effect:

string ab = "a\tb";

The problem you have is not with creating the string, but with displaying the string. You are probably using a control that doesn't support displaying tabs. It might be better to replace the tabs with spaces.

Related

5
  • is it then possible to right align that string (because it is multiline)
    – Buena
    Jun 25, 2012 at 19:19
  • @Buena: Can't you just use two separate labels?
    – Mark Byers
    Jun 25, 2012 at 19:20
  • No, lines are created from dgvRows, it could be 5 lines
    – Buena
    Jun 25, 2012 at 19:21
  • @Buena: How about a RichTextBox then? You can make it non-editable.
    – Mark Byers
    Jun 25, 2012 at 19:23
  • Hm, I'll try. Thanks to EveryOne. But every day I find some limitations in C# and VS.
    – Buena
    Jun 25, 2012 at 19:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.