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.
Related
I want to be able to bind content control fields to each others' values. Basically if you change a field at the top, all others in the document also update to that. I'm replacing hundreds of individual variables, each with 100 duplicates. There is a better way than the 'Find and Replace Tool'.
Here is a sample document directly from Microsoft's site that shows exactly what I would like to be able to do:
https://omextemplates.content.office.net/support/templates/en-us/tf03444179.dotx
When the '' value is changed, all others in the document update.
I've already looked at plenty of solutions like: c# word interop find and replace everything
But they do not dynamically respond during run-time. In other words you have to go in and change which string you want to replace for each value.
Been looking for a while now, thanks in advance if anyone else can figure this out.
I believe am in need of creating custom RichTextBox in C#. One kind of like that:
I admit it might not even have to be RichTextBox, but after some research I decided it's gonna be the easiest way. Functionality I need are icons at each row, checkboxes and text formatting. My program will process each line of the text and mark lines that are correct, incorrect, and strike out lines not necessary in further work, while showing line that's currently processed and allowing user to edit some lines freely (here: lines before Around 3 000 won't be editable, but those under the line will).
What's the problem then? I have no idea how to get it done. I've seen tutorial on how to make single-line textBox with icon or checkbox nearby, but I have no idea how to make both, and for multiline textBox (so I could freely scroll and everything would work fluently). I've read some questions on SO as well, but neither helped me.
I just don't know how to get started, I realize it won't be 5 min work, but I'm willing to do it. Until now I've been only able to create custom control deriving from RichTextBox, but I have no idea which methods and how to override. Any help appreciated.
Try to use WebBrowser control instead RichTextBox.
You can add CheckBoxes and editable content by setting a correct HTML code to it.
Set each TextBox or CheckBoxes ids and use GetElementsByTagName or GetElementById to access inner elements to get or set its attributes or values.
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.
I want to be able to read text from a Silverlight TextBlock (TextBlock Control) (Silverlight & C#) and check what formatting (as in: bold, italic, font size, etc...) has been applied to it, so I can store it in an XML file.
Is it possible to find out what formatting has been applied to a piece of text with C# and Silverlight so it can be stored and re-used later? The text would be contained within a textbox or textblock control.
Storage used can be XML but I've just found out Silverlight doesn't support XSL, so just XML.
Regards,
T
Just make sure you give your control a name.
<Textblock x:Name="myTextBlock" />
In your code behind you can then access the TextBlock but calling it's name (myTextBlock).
Here you can add logic like:
if (myTextBlock.FontWeight == "Bold")
{
//Do Something
}
From reading your needs you'll most likely be passing the object to a function and creating your xml file from there. Good luck.
By formatting you mean a phone number or date format?
If yes. Use regular expressions.
Take a look at the System.Text.RegularExpressions namespace. Everything there should help you.
I'm developing an advanced rich text editor in c# but have stumbled upon a problem that I can't seem to grasp.
I have been trying to let users save their documents as Text files (plain text). By using the following:
MyRichTextBox.SaveFile(filepath, PlainText);
But the problem is that when they view that file (which should have been saved as plain text) in Notepad, it shows up with all of the RTF formatting codes whish makes their documents unreadable. Does anybody know of any other way to remove formatting codes from a RichTextBox without having to do too much?
I mean, if there's going to be alot of work involved in finding a workaround to such a simple task, I might as well just create my own RichTextBox control from scratch. Which I'm sure would be very hard to do, but atleast I know that it'll work...
... Sorry for ranting on a little there, hehe...
Thanks All,
Jason.
This should do it:
String txt = MyRichTextBox.Text
File.WriteAllText(filepath, txt);
Alternatively, the way to get the RTF is:
String rft = MyRichTextBox.Rtf;
File.WriteAllText(filepath, rtf);
Have you tried:
RichTextBoxStreamType.PlainText
instead of:
PlainText