richtextbox

Winforms RichtextBox Bold/Italic/Underline Formatting issue

霸气de小男生 提交于 2019-12-10 15:25:47
问题 As you can tell from the title, Im having a bit of issue regarding assigning and removing format styles to and from selected text in the RichTexBox control. I know how to make text individually Bold/Italic/Underline, but not a combination of these. I know of ways that can achieve this character by character, but this would seem time-consuming on the interface. If it can be effortlessly done in Wordpad, Im sure it can be achieved here! Is there no such method or such that exists that can allow

How to have alternating line colors for a Winforms RichTextBox?

心已入冬 提交于 2019-12-10 15:12:05
问题 Something that looks like this: Is there a line-like property where I could do?: foreach line ... line.BackColor = Colors.Gray; Lines[i] property returns just a string. 回答1: A not so great solution would be to append extra text onto each line and then highlight the full text. So something like this: // Update lines to have extra length past length of window string[] linez = new string[richTextBox1.Lines.Length]; for (int i = 0; i < richTextBox1.Lines.Length; i++) { linez[i] = richTextBox1

WPF RichTextBox Document Creation Threading Issue

巧了我就是萌 提交于 2019-12-10 14:46:50
问题 I'm having a bit of an issue with a RTB and document generation in regards to threads. When the TextChanged event fires on the RTB, a new thead is created, and the document generation is offloaded to this. This can take a couple of seconds, with blocking calls, so it really needs to be on another thread to keep the UI responsive. The problem I'm having is an exception when I try to add the newly generated document to the Document property of the RTB. ( The calling thread cannot access this

Set specific text to bold in WPF RichTextBox

我的未来我决定 提交于 2019-12-10 13:45:50
问题 I am extending the functionality of a WPF Richtextbox. I want certain text to become bold when I type it in. I was able to get certain text to bold but the text following the bolded word would also become bolded... Heres a sample of my code: private bool _Running = false; void CustomRichTextBox_TextChange(object sender, TextChangedEventArgs e) { if(_Running) return; _Running = true; //Logic to see if text detected //Logic to get TextPointers //Logic to get TextRange var boldMe = new TextRange

Underline not detected after reloading RTF

一个人想着一个人 提交于 2019-12-10 13:15:36
问题 I'm currently trying to get a RichTextBox with basic formatting working for my new beta notes software, Lilly Notes. Brian Lagunas' article on the subject put me in the right direction, however I'm having a bit of an issue. If you click on underlined text, the Underline button becomes pressed, so the state is being recognised. However if I serialize it to RTF and then deserialize it back into the RichTextBox, then it doesn't get detected. Since the code in Lilly Notes is not trivial to

Determine if selected text is Hyperlink in RichTextBox?

孤者浪人 提交于 2019-12-10 12:14:57
问题 I also am hoping to populate a text box with the URL of the selected Hyperlink. I think I am along the right path with this code, but I don't know how to complete it: TextPointer position = RichTextBoxEditor.Selection.Start; Inline parent = position.Parent as Inline; foreach (Hyperlink hl in RichTextBoxEditor.Blocks.OfType<Hyperlink>()) { } 回答1: Yes... you are in the right path. Never done before but if your cursor is inside an hyperlink this gives you the hyperlink: TextPointer position1 =

Dragging files into rich textbox to read text in file

a 夏天 提交于 2019-12-10 11:38:37
问题 I'm having a problem with dragging and dropping files onto a richTextBox, every time I drag a text file onto it, it turns into a picture of the text file with its name under it. Double click the file and it opens up using the system default application (ie notepad for text files, etc). basically its making shortcuts in the richTextBox, when i want it to read the text in the file. Based on this code, the text from the file should extract into richTextBox1 class DragDropRichTextBox :

DocumentViewer to RichTextBox Binding Error

你。 提交于 2019-12-10 11:25:08
问题 I have an application with RichTextBox and DocumentViewer (placed in a TabControl), and I want to make something like "hot preview". I've binded DocumentViewer.Document property to RichTextBox.Document Binding: <DocumentViewer Document="{Binding Document, Converter={StaticResource FlowDocumentToPaginatorConverter}, ElementName=mainRTB, Mode=OneWay}" /> And this is Converter code: public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {

Creating custom RichTextBox control

不问归期 提交于 2019-12-10 10:58:59
问题 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

KeyBinding gesture “Ctrl+1” in RichTextBox doesn't work

别来无恙 提交于 2019-12-10 10:36:10
问题 There is a strange difference when binding commands to Ctrl+N gestures in WPF. Some but not all of these gestures are ignored, while the rest are ok. Did anyone else experience this behavior by any chance? Window XAML structure is very simple: command binding, input binding, and a DockPanel with Menu and RichTextBox. After testing, the problem appears only when input focus is in RichTextBox. For the test, Window input binding was defined for all numeric keys as shown below. As a result, Ctrl