Insert paragraph between text of richtextbox and change font and color of added paragraph

Go To StackoverFlow.com

2

my text is in richtextbox :

<Parag1 Level="One">
First text of parag1. Second text of parag1.
</Parag1>
<Parag2 Level="Two">
First text of parag2. Second text of parag2.
</Parag2>
<Parag3 Level="Footer">
First text of parag3. Second text of parag3.
</Parag3>
<Parag4 Level="Three">
First text of parag4. Second text of parag4.
</Parag4>

The font of all tags with level One, Two, Three is Arial, Size = 9, Color = Red Example : <Parag1 Level="One"> Or </Parag4>

The font of text between tags with level One, Two, Three is MicrosoftNewRomans, Size = 12, Color = Black Example : First text of parag2. Second text of parag2.

The font of text between tags with level Footer is Tahoma, Size = 10, Color = Blue Example : First text of parag3. Second text of parag3.

I want add this paragraph between tags 3 & 4. example :

 <NewParag5 Level="Footer">
This tags between 3 and 4.
</NewParag5>

Question : How can I do it with same font and color for seperate part of paragraph. this mean without change font and color of my other text, I can insert paragraph to richtextbox and then for tags change font or color to red, for text change to blue.

Please help me for c# and winforms richtextbox.

Thank's.

Question 2 : How to add a paragraph between text, that font and color of parts of paragraph are set to tag font style & text save ago style(font & color).

2012-04-03 23:15
by Ali Ahmadi


0

I would try this approach : RadioButton.

If you add a few of them to your solution, you can check if the text entered is a tag, a paragraph etc..

E.g.

       if(tagRadioButton.Checked)
       {
          //Colors , Fonts Selection logic.
       }

If you don't want to use any radio buttons than you could search the imputed string for keywords and change the colors and fonts depending on what is being imputed. I'm sure you can find a good tutorial on that but because i'm not really good with string manipulation.

Hope this helps.

2012-04-04 16:14
by phadaphunk
Oh. Just for next the next time you have to add a question like this you can simply edit the previous question and add an Update part : - phadaphunk 2012-04-04 16:17
Thank's from your reply, my friend PhaDaPhunk - Ali Ahmadi 2012-04-05 04:33
No problem. Dont forget to mark this question as answered if you found out what you where looking for : - phadaphunk 2012-04-05 11:20
Ads