c# - New Line Character is not shown in TextBox -
i have form shown in image below:
now, when user clicks on save template
, save text of textbox in xml file. code use save text in xml file :
public static void savetemplate(string message) { xdocument xmldocument = xdocument.load(templatespath); xmldocument.element("templates").add( new xelement("template", new xattribute("id", xmldocument.root.elements("template").lastordefault() != null ? int.parse(xmldocument.root.elements("template").lastordefault().attribute("id").value) + 1 : 1), new xelement("body", message))); xmldocument.save(templatespath); }
the text saved in xml file looks like:
after user may whatever wants. when user runs application again, textbox empty. so, click on load template
button. @ time text shown in datagridview:
now, user clicks on select template
, text datagridviewcell copied textbox again. text not contain new lines. @ image below:
does experienced same problem in past?
i had replace \n
environment.newline
like:
_frmmsgdetails.messagebody = dgvtemplates.selectedrows[0].cells[2].value.tostring() .replace("\n", environment.newline);
Comments
Post a Comment