detect if text in RichtextBox is formatted

PhilippR

New member
Joined
Jul 13, 2006
Messages
2
Location
Germany
Programming Experience
3-5
Hi there,

btw. I'm new here, Philipp from germany - hello everybody! ;)

I'm using a RichtextBox in my Tool and i want to determine if the User made any RTF-related changes (font style bold, italic, etc... test alignment, font size etc. etc.) to the text in the RTF box. (I want to transmit the data and if the user just used plaintext i just want to read out the plaintext (RichtextBox1.Text instead of RichtextBox1.Rtf) - similar to common email-clients ("Do you want to send your email in plaintext or as HTML").
So does anybody know how to determine if the user formatted the text (RTF) or just wrote standart-plaintext into the box?

Thank you very much!!

Philipp
 
You can select all text and check the SelectionFont and SelectionColor properties, if SelectionFont is Nothing then there are different fonts in selection, if SelectionColor is Color.Empty then there are different colors in selection. If they do return a font and color you can compare with default RTB.Font and RTB.ForeColor to see if different.

A consideration for you is to let user choose edit mode, rich mode or plain mode. Depending on the current user edit mode you would know what type of data to transmit. For example user may copy formatted text and want to paste into your editor, but wants the transmission to be plain text.
 
Back
Top