1
votes

I read a text file from the hard drive, then I want to put this text in a textbox and keep the same formatting from the file (the tabulations for example).

When I open the file in a simple notepad, the formatting is good, but when putting the text in the textbox, the formatting is kind of weird, i.e:

UPDATE MYTABLE
SET ID                         = :id, 
    THENAME                       = :name,
    INFO                       = :info,  
    FILESIZE                       = :size,
    COMPLETEPATH                       = :path

Instead of:

UPDATE MYTABLE
SET ID                         = :id, 
    THENAME                    = :name,
    INFOS                      = :info,  
    FILESIZE                   = :size,
    COMPLETEPATH               = :path

How can I keep the formatting? I tried with the methods of StreamReader and File (ReadToEnd, ReadLine, ReadAllText) with all encoding available (UTF7, UTF8, UTF32, ASCII, UNICODE, BigEndianUnicode).

1
It is reading the file so I doubt encoding is the problem. What is interesting is the first indent is correct. Examine the space characters between the two column. I suspect tabs are used but not treated the same. - paparazzo

1 Answers

2
votes

I guess the problem is simply the Font - Have you set the font of the textbox to a monospace font (e.g. Courier)?

If you set it to e.g. Times New Roman or Calibri not all letters have the same width resulting in what you described...