• 0

[C#] Display non-printable characters as spaces


Question

OK this is kind of an odd one.

What I'm looking to do is take a string of of text with linebreaks in it, and display it in a text box. For size reasons (long strings) I would like it to word wrap as nomal, based on the length of the control, and not based on the linebreak location. However for editing (and parsing) reasons, I would like the linebreaks to remain.

Now this is all fine and good, and easy to do... If you don't mind the not-printable character (little square) showing up, left, right and center.

What I would like to do is display the linebreak as as a good old fassion space. Now I know I could string.Replace(inputText, "\n", "");

But again once editing is done, I would like the linebreaks to still be in the string.

I don't know that there is any reasonabley easy way to do this (and have a feeling there isn't). But I thought I'd pick the brains of you bright folks any way.

TIA!!!

3 answers to this question

Recommended Posts

  • 0

It is, the TextBox is sized dynamically at runtime. The real issue is the the textBox's length can hold around 75 characters, and the linebreaks are at about 35 (give or take). Leaving a whole lot of room left in the TextBox control. Now since TextBoxes ignore linebreaks, and word wrap at the end of the control, it's works well (and is also the reason I can't use a RichTextEdit) but all the line breaks show up as the not-printable character.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.