G
Guest
Hey guys,
I'm trying to set the Rtf property of a Richtextbox and I'm having some
issues.
First I do this, which works fine:
string test =
@"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0
Arial;}}
{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\ul\f0\fs20
Test\ulnone\par}";
this._agreementTextBox.Rtf = test;
The textbox displays the underlined word "Test".
However, when I try to do the same thing but instead read the rtf from a
CDATA section in an xml file, I get an exception thrown:
Here is the XML:
<Options>
<Item key="CLICK_THROUGH_TEXT"><![CDATA[
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0
Arial;}}
{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\ul\f0\fs20
Test\ulnone\par
}
]]></Item>
</Options>
Code:
string xPath = String.Format("Item[@key='{0}']", Settings.CLICK_THROUGH_TEXT);
XmlNode node = agreementConfig.GetNode(xPath,null);
if (node != null)
{
this._agreementTextBox.Text = node.InnerText;
}
This throws an System.ArgumentException: Invalid file format.
at System.Windows.Forms.RichTextBox.StreamIn(Stream data, Int32 flags)
Can anyone tell me how I can read it from the xml and get it to work properly?
THanks,
-Flack
I'm trying to set the Rtf property of a Richtextbox and I'm having some
issues.
First I do this, which works fine:
string test =
@"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0
Arial;}}
{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\ul\f0\fs20
Test\ulnone\par}";
this._agreementTextBox.Rtf = test;
The textbox displays the underlined word "Test".
However, when I try to do the same thing but instead read the rtf from a
CDATA section in an xml file, I get an exception thrown:
Here is the XML:
<Options>
<Item key="CLICK_THROUGH_TEXT"><![CDATA[
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0
Arial;}}
{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\ul\f0\fs20
Test\ulnone\par
}
]]></Item>
</Options>
Code:
string xPath = String.Format("Item[@key='{0}']", Settings.CLICK_THROUGH_TEXT);
XmlNode node = agreementConfig.GetNode(xPath,null);
if (node != null)
{
this._agreementTextBox.Text = node.InnerText;
}
This throws an System.ArgumentException: Invalid file format.
at System.Windows.Forms.RichTextBox.StreamIn(Stream data, Int32 flags)
Can anyone tell me how I can read it from the xml and get it to work properly?
THanks,
-Flack