Click here to Skip to main content
15,794,475 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I am stuck in an issue,I have to show XML content in Richtextbox and do formatting as per element name , My problem is this that when i use RichtextBox selected property and font property than i lose all containing data of Richtextbox and, than how to format only that specific line or part of text .

foreach (XElement detail in doc.Descendants("title"))// put section ID

richTextBox1.SelectedText = detail.Value;
richTextBox1.SelectionFont = new Font("arial", 18);

detail.Value = Environment.NewLine + detail.Value + Environment.NewLine ;


I have tried it both of way by RTF and but text but problem is that, i am using XML file to read. and when i try to read specific element and formate it than it replace whole content of text box .

and if i try it using replace of string than my another data(which have same words) also formatted . as a part of XML

<section level="1" number-type="manual" num="2">
<title>Modalit&#x00E9;s d&#x2019;application de l&#x2019;absence</title>
<section num="1." number-type="manual" level="sect2">
<para align="left">Le travailleur peut s&#x2019;absenter pendant le &#x00AB;d&#x00E9;lai de pr&#x00E9;avis&#x00BB;.</para>
<para align="left">Seul le contrat de travail &#x00E0; dur&#x00E9;e ind&#x00E9;termin&#x00E9;e peut &#x00EA;tre rompu moyennant pr&#x00E9;avis. La r&#x00E9;glementation ne s&#x2019;applique donc pas aux contrats de travail &#x00E0; dur&#x00E9;e d&#x00E9;termin&#x00E9;e ou pour un travail nettement d&#x00E9;fini. ABSENCE PENDANT LE &#x00AB;DELAI DE PREAVIS&#x00BB;..</para>

now what i did, get all text of XML in richtext box than try to format <title> element data,

and when i try it as above code it replace whole data and show only <title>
Updated 15-Jan-15 21:04pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900