Strange Behaviour with MultiLine Textbox Control

Z

zacks

I am developing an app in VS2005 (actually in VB.NET but this
question, I believe, would apply to any .NET language) that is used to
design the contents of an XML file. One of potential items that would
be in this XML file is a String property that contains the code for a
VBScript. I have a separate form just for editing this script that
uses a single Textbox. This Textbox has the AcceptsReturn, AcceptsTab
and Multiline properties all set to True. I can create a new script
just fine and save it in the XML file. But if I re-load that XML file
for editing, and open the form with the contents of the script from
the XML file in it, all carraige returns are ignored. Oh, they are
definitely there, if you look at the XML file file with a hex editor,
there are definite <CR><LF> at the end of each of the scripts lines.
What is really strange is if I create a new script and re-edit it
before saving the XML and re-loading it, the carraige returns are
"displayed" in the Textbox as one would expect.

As I said, the XML file is fine. The problem come in when trying to
edit an existing script that has carraige returns in it.
 
Z

zacks

I am developing an app in VS2005 (actually in VB.NET but this
question, I believe, would apply to any .NET language) that is used to
design the contents of an XML file. One of potential items that would
be in this XML file is a String property that contains the code for a
VBScript. I have a separate form just for editing this script that
uses a single Textbox. This Textbox has the AcceptsReturn, AcceptsTab
and Multiline properties all set to True. I can create a new script
just fine and save it in the XML file. But if I re-load that XML file
for editing, and open the form with the contents of the script from
the XML file in it, all carraige returns are ignored. Oh, they are
definitely there, if you look at the XML file file with a hex editor,
there are definite <CR><LF> at the end of each of the scripts lines.
What is really strange is if I create a new script and re-edit it
before saving the XML and re-loading it, the carraige returns are
"displayed" in the Textbox as one would expect.

As I said, the XML file is fine. The problem come in when trying to
edit an existing script that has carraige returns in it.

Sorry for the waste of bandwidth, but I just figured this out. The XML
file being edited is loaded and written using the XMLSerializer class.
For some strange reason, when I de-serialize the XML file, any string
value that contains embedded <CR><LF>, all occurances of them are
replaced with a <LF> only. But when the class is serialized, the <LF>
are then replaced by <CR><LF>!!! I wonder why?

Anyway, the problem was solved by adding a .Replace(vbLf, vbCrLf) as
the text box .Text property was loaded.
 
G

Guest

strange


Windows ( DOS ) based systems uses two characters (carriage-return and
line-feed), to signal the end of a line, while UNIX based systems uses only
one (line-feed).

As .Net ( and especially the XML / webservices ) is platform independend i
guess some conversion routine doesn`t work as expected




regards

Michel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top