Click here to Skip to main content
15,905,148 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an extended richTextBox inside an app, which is to be filled with text by the user.. I have some buttons for different formating options.
Let's say inside the text there are 3-4 chapters. The titles of the chapters are all written using the same style/font/color. What I want is a means to identify those titles inside the text document.
Any ideas?
Posted

1 solution

Not the most elegant way would be to simply traverse the text, selecting each character one by one, get it's font and match the properties you are looking for. Each time a match is found you simply hold on to the start position and then search for the end by finding a mismatch or the end of the text.

Here you have a sample how to check the font. Traversing and selecting should be a peace of cake.

http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.selectionfont.aspx[^]

Maybe this article here on the codeproject might also be helpful and could supply you with another way of searching on these font properties.

NRTFTree - A class library for RTF processing in C#[^]

Good luck!
 
Share this answer
 

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