richtextbox

simple text color in rich text box

这一生的挚爱 提交于 2019-12-23 14:41:35
问题 I can find a million examples of doing reg ex to apply syntax highlighting to a rich text box. but what i need it just a simple way to add in a word of a diffrent color. What would the code be to just put the words "Hello World" into a textbox and have Hello be red and World be green? This code doesnt work. this.richTextBox1.SelectionColor = Color.Red this.richTextBox1.text += "Test" 回答1: Select the text after you put it in and then change the color. For example: richTextBox1.Text += "Test"

simple text color in rich text box

大兔子大兔子 提交于 2019-12-23 14:40:56
问题 I can find a million examples of doing reg ex to apply syntax highlighting to a rich text box. but what i need it just a simple way to add in a word of a diffrent color. What would the code be to just put the words "Hello World" into a textbox and have Hello be red and World be green? This code doesnt work. this.richTextBox1.SelectionColor = Color.Red this.richTextBox1.text += "Test" 回答1: Select the text after you put it in and then change the color. For example: richTextBox1.Text += "Test"

How do I jump to a specific line in a RichTextBox?

南楼画角 提交于 2019-12-23 13:38:22
问题 I'm looking for an example code how to jump to a specific line of a RichTextBox in WPF. I have no idea how to do this, in winForms it is very simple because I'm free to can set SelectionStart and SelectionLength that unlike in WPF the equivalent properties are read only. 回答1: You have some options in the API: LineDown ScrollToVerticalOffset ScrollToEnd 来源: https://stackoverflow.com/questions/9013029/how-do-i-jump-to-a-specific-line-in-a-richtextbox

How to print line numbers for textbox in c#

寵の児 提交于 2019-12-23 12:56:07
问题 This is going to be a long post. I would like to have suggestions if any on the procedure I am following. I want the best method to print line numbers next to each CRLF-terminated-line in a richtextbox. I am using C# with .NET. I have tried using ListView but it is inefficient when number of lines grow. I have been successful in using Graphics in custom control to print the line numbers and so far I am happy with the performance. But as the number of lines grow to 50K to 100K the scrolling is

C# - RichTextBox change color of certain words [duplicate]

Deadly 提交于 2019-12-23 12:18:53
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to select text from the RichTextBox and then color it? I don't really have any code to show, because I don't know :(. I have a server that outputs information with tags. For example: 15:44 [INFO] Loaded Properties 15:45 [ERROR] Properties not found How do I look in the richtextbox and make all ERROR tags red, INFO tags GREEN, etc.? 回答1: I think this should do what you want: for(int i=0; i<rtb.Lines.Length; i

WPF. How to align text in InlineUIContainer content with outer text in RichTextBox

心已入冬 提交于 2019-12-23 10:04:08
问题 The task: Make the text content of the InlineUIContainer to be inline with the outer text The standard behaviour of the InlineUIContainer content is when the bottom edge is inline with the outer text. It is possible to shift the content of InlineUIContainer with RenderTransform, but the value of Y has to be chosen for each font type and size - not a perfect way. <RichTextBox> <FlowDocument> <Paragraph> LLL <InlineUIContainer> <Border Background="LightGoldenrodYellow"> <TextBlock Text="LLL"/>

WPF RichTextBox scroll to TextPointer

早过忘川 提交于 2019-12-23 09:52:08
问题 The WPF RichtTextBox has a method to scroll: RichTextBox.ScrollToVerticalOffset(double) I want to scroll in such a way, that a certain range or at least the start of it comes into view. How can I convert a TextPointer to double in a meaningful way? 回答1: Have a look at the FrameworkElement.BringIntoView Method. I'm using something like this: public void Foo(FlowDocumentScrollViewer viewer) { TextPointer t = viewer.Selection.Start; FrameworkContentElement e = t.Parent as FrameworkContentElement

Coloring Text in RichtextBox, C#

两盒软妹~` 提交于 2019-12-23 09:24:01
问题 How can I color new line of text with some different colors and then add it to RichTextBox? I'm using SilverLight. 回答1: You can do this in code: // Create a paragraph with two coloured runs Paragraph para = new Paragraph(); Run run1 = new Run("Red "); run1.Foreground = Brushes.Red; Run run2 = new Run("Green"); run2.Foreground = Brushes.Green; para.Inlines.Add(run1); para.Inlines.Add(run2); // Get the document FlowDocument doc = richTextBox1.Document; // Clear existing content doc.Blocks.Clear

Link to file path with space in Richtextbox

倾然丶 夕夏残阳落幕 提交于 2019-12-23 04:47:43
问题 I am using richtextbox in winforms. I have to show some links in the richtextbox which will be set readonly. It works fine for the links with out spaces like \\efile\DSC_0618.JPG But when the file has space like \\2527 threshold.png it wont work and link will get broke due to space. i have used the solution mentioned in this link Link to File's path with spaces in RichTextBox? But the problem is that escape sequence also get displayed in the Richtextbox according to that. Is there any way i

Insert Image in RichTextBox along with Text C#

拟墨画扇 提交于 2019-12-23 04:44:12
问题 I'm trying to insert images in my rich text box in C#, but so far I'm only failing. Miserably. This is the code that I am using: Clipboard.SetImage(Image.FromFile(Application.StartupPath + @"\PIC\" + i + ".bmp")); chat.Paste(); The real problem is I am not able to put both text and image in the textbox. The moment I insert text after copying the image the image disappears. I am unable to find a solution for this Can anybody help me with this? Please??? Thanks 回答1: RichTextBox rtb = new