Strange Behaviour with MultiLine Textbox Control

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • zacks@construction-imaging.com

    #1

    Strange Behaviour with MultiLine Textbox Control

    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><LFat 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.

  • zacks@construction-imaging.com

    #2
    Re: Strange Behaviour with MultiLine Textbox Control

    On Jun 21, 10:12 am, z...@constructi on-imaging.com wrote:
    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><LFat 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 <LFonly. 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.

    Comment

    • =?Utf-8?B?TS4gUG9zc2V0aA==?=

      #3
      Re: Strange Behaviour with MultiLine Textbox Control

      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






      "zacks@construc tion-imaging.com" wrote:
      On Jun 21, 10:12 am, z...@constructi on-imaging.com wrote:
      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><LFat 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 <LFonly. 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.
      >
      >

      Comment

      Working...