Harry Boy Harry Boy - 1 month ago 17
C# Question

String formatting not displaying corectly

I am reading incoming text streams in my C# app, when I look at each string in the debugger and copy and paste its contents into Notepad++ I see that there is clear formatting like so:

SEMI MILK 1 1.19
PERSIL WUL 1 1.00
BUR JAM DODG 1 1.25


But when I add each string to a List and display on screen like so I see that the formatting is off:

enter image description here

How can I get the text to diaplay exactly the same as it displays in Notepad++

The display is made up as follows:

1. DataGrid _dataGrid;
2. _dataGrid.ItemsSource = TextContent;
3. TextContent = new ObservableCollection<Textline>();
4. TextContent is simply a class with a string Property to store any text for display.

Answer

You will probably have to change the font of your DataGrid, try a monospaced font like Courier, Courier New, Lucida Console, Monaco or Consolas. You can also go to your Notepad++ and find the font it is using if you want the same look and feel.

Comments