richtextbox

Selectively coloring text in RichTextBox

孤街醉人 提交于 2019-11-26 08:30:21
问题 How can I paint in red every time I meet the letter \"A\" in RichTextBox? 回答1: Try this: static void HighlightPhrase(RichTextBox box, string phrase, Color color) { int pos = box.SelectionStart; string s = box.Text; for (int ix = 0; ; ) { int jx = s.IndexOf(phrase, ix, StringComparison.CurrentCultureIgnoreCase); if (jx < 0) break; box.SelectionStart = jx; box.SelectionLength = phrase.Length; box.SelectionColor = color; ix = jx + 1; } box.SelectionStart = pos; box.SelectionLength = 0; } ...

A textbox/richtextbox that has syntax highlighting? [C#] [closed]

两盒软妹~` 提交于 2019-11-26 08:04:43
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . Where can I find a control for WinForms that will highlight source code pasted into it? I would like one that has syntax highlighting support for many different languages but if it only works with C# I would be fine with that also. 回答1: Scintilla.NET is probably what you're looking for 回答2: Just recently have

RichTextBox (WPF) does not have string property “Text”

故事扮演 提交于 2019-11-26 07:25:35
I am trying to set/get the text of my RichTextBox, but Text is not among list of its properties when I want to get test.Text... I am using code behind in C# (.net framework 3.5 SP1) RichTextBox test = new RichTextBox(); cannot have test.Text(?) Do you know how come it can be possible ? to set RichTextBox text: richTextBox1.Document.Blocks.Clear(); richTextBox1.Document.Blocks.Add(new Paragraph(new Run("Text"))); to get RichTextBox text: string richText = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd).Text; There was a confusion between RichTextBox in System

RichTextBox syntax highlighting in real time--Disabling the repaint

时光怂恿深爱的人放手 提交于 2019-11-26 05:26:39
I'm creating a function that takes a RichTextBox and has access to a list of keywords & 'badwords'. I need to highlight any keywords & badwords I find in the RichTextBox while the user is typing , which means the function is called every time an editing key is released. I've written this function, but the words and cursor in the box flicker too much for comfort. I've discovered a solution--to disable the RichTextBox's ability to repaint itself while I'm editing and formatting its text. However, the only way I know to do this is to override the "WndProc" function and intercept (what I've been

Textarea that can do syntax highlighting on the fly?

不想你离开。 提交于 2019-11-26 04:58:31
问题 I am storing a number of HTML blocks inside a CMS for reasons of easier maintenance. They are represented by <textarea> s. Does anybody know a JavaScript Widget of some sort that can do syntax highlighting for HTML within a textarea or similar, while still staying a plain text editor (no WYSIWYG or advanced functions)? 回答1: It's not possible to achieve the required level of control over presentation in a regular textarea. If you're OK with that, try CodeMirror or Ace (formerly skywriter and

Richtextbox wpf binding

自古美人都是妖i 提交于 2019-11-26 03:33:08
问题 To do DataBinding of the Document in a WPF RichtextBox , I saw 2 Solutions so far, which are to derive from the RichtextBox and add a DependencyProperty, and also the solution with a \"proxy\". Neither the first or the second are satisfactory. Does somebody know another solution, or instead, a commercial RTF control which is capable of DataBinding ? The normal Textbox ist not an alternative, since we need text formating. Any idea? 回答1: I know this is an old post, but check out the Extended

Color different parts of a RichTextBox string

↘锁芯ラ 提交于 2019-11-26 03:15:06
问题 I\'m trying to color parts of a string to be appended to a RichTextBox. I have a string built from different strings. string temp = \"[\" + DateTime.Now.ToShortTimeString() + \"] \" + userid + \" \" + message + Environment.NewLine; This is what the message would look like once it is constructed. [9:23pm] User: my message here. I want everything within and including the brackets [9:23] to be one color, \'user\' to be another color and the message to be another color. Then I\'d like the string

How can I insert an image into a RichTextBox?

泄露秘密 提交于 2019-11-26 02:54:41
问题 Most of the examples I see say to put it on the clipboard and use paste, but that doesn\'t seem to be very good because it overwrites the clipboard. I did see one method that manually put the image into the RTF using a pinvoke to convert the image to a wmf. Is this the best way? Is there any more straightforward thing I can do? 回答1: The most straightforward way would be to modify the RTF code to insert the picture yourself. In RTF, a picture is defined like this: '{' \pict (brdr? & shading? &

RichTextBox (WPF) does not have string property “Text”

可紊 提交于 2019-11-26 01:58:10
问题 I am trying to set/get the text of my RichTextBox, but Text is not among list of its properties when I want to get test.Text... I am using code behind in C# (.net framework 3.5 SP1) RichTextBox test = new RichTextBox(); cannot have test.Text(?) Do you know how come it can be possible ? 回答1: to set RichTextBox text: richTextBox1.Document.Blocks.Clear(); richTextBox1.Document.Blocks.Add(new Paragraph(new Run("Text"))); to get RichTextBox text: string richText = new TextRange(richTextBox1

RichTextBox syntax highlighting in real time--Disabling the repaint

你。 提交于 2019-11-26 01:54:37
问题 I\'m creating a function that takes a RichTextBox and has access to a list of keywords & \'badwords\'. I need to highlight any keywords & badwords I find in the RichTextBox while the user is typing , which means the function is called every time an editing key is released. I\'ve written this function, but the words and cursor in the box flicker too much for comfort. I\'ve discovered a solution--to disable the RichTextBox\'s ability to repaint itself while I\'m editing and formatting its text.