Finding RTF code associated with selected text in RichTextBox - c#

I am using winform RichTextBox and I wonder if we can find the corresponding rtf code (or at least whereabouts of it) when selecting text?

Use the SelectedRtf property.

Related

A method to visually separate text lines in Richtextbox

I would like to know if there is an easier way to add any kind of visual separation like a line between text lines in a Richtextbox?
If not, is there another component that I can use in a Form that would be able to do this for text lines?
Thank you.
It has been a few years, but at one point I wrote a RichTextBox wrapper that ended up manipulating the underlying markup. It wasn't pretty and it wasn't for the faint of heart, but it did work. I ended up using it to highlight some text I believe.
The key thing you need to know is the specification for the RTF markup language: http://en.wikipedia.org/wiki/Rich_Text_Format should get you started.
The RichTextBox class documentation and the Document property should get you started at modifying the underlying structure of the document after loading or during editing.

looking for text control that is easy to data bind and text highlight wpf

I am looking for some control that can do following 2 :
1.highlight some of the text in different colors.
easy databind.
checked richtextbox - but it is hard to databind with it.
checked textbox but it problem to text hight light with it.
any suggestions
Use the RichTextBox - or even better the Extended RichTextBox here (it allows easy DataBinding): http://wpftoolkit.codeplex.com/wikipage?title=RichTextBox.
If you don't want to have to include another control you can create an AttachedProperty to make it possible to bind to the built in RichTextBox. Check this out here: http://michaelsync.net/2009/06/09/bindable-wpf-richtext-editor-with-xamlhtml-convertor

put \\scaps in RTF for small caps

I'm using dynamic RichTextBox control in C# 2.0 and I want to insert "\scaps" in RTF so that if the file is saved programatically and then opened in MS-Word certain text be seen smallcaps.
Can anyone tell me the code as how to insert the tag?
Well, you can access the rich text directly through the Rtf property on the rich text box.

Saving Image embedded in Silverlight RichTextBox

I am currently working on a Silverlight project and I am using RichTextBox. User are allowed to drag and drop images on to the RTB. I know that the Xaml property a Silverlight RichTextBox doesn't not include any UIElement objects that are present in the content and I need to save the content of this RTB and later load it. Does anyone know of a way to achieve this? Thanks.
You're probably better off traversing the all of the Inlines in the RTB. The InlineUIContainers are Inlines so you can handle those however you'd like.
Your basic strategy should look something like:
Get the Blocks property of the RTB, find all the Paragraphs. Get the Inlines on each Paragraph. For each inline: handle a Run and save as Text. handle InlineUIContainer and save as however you'd like. Handle a Span as a recursive call to find the child Inlines.
If you want to save formatting on the Runs, then you'll have even more code for that.
It's not nearly as easy as using the Xaml property but it's really the only way to handle controls in InlineUIContainers.

Selectable TextBlock or a TextBox with formatted text in WPF

I have a situation where I need to show a formatted text (normal, bold, highlighted) and should also be selectable so that user can copy the text.
I have used textblock where i can apply multiple formattings using Inline content flow elements but unfortunately it's text is not selectable.
Whereas Textbox allows to select text and copy to clipboard, it does not allow me to format text.
Is there anything I am missing or I'll have to build a custom control?
I'm not sure how much style you're wanting to apply, but I find the following site to be useful to determine the best way to use Silverlight controls:
http://samples.msdn.microsoft.com/Silverlight/SampleBrowser/index.htm#/
This specific URL has some information on how to style a Textbox:
http://samples.msdn.microsoft.com/Silverlight/SampleBrowser/index.htm#/?sref=TextBoxSnippet
You can use RichTextBox. It control is selectable and support formatted tex.

Categories

Resources