Append Text with Color?
See original GitHub issueHi, new to this control. I’d like to append text to the box with a set color. With the WinForms RichTextBox I would do something like this:
private void AppendTextToLogBoxWithColor(string text, Color color)
{
richTextBoxLog.SelectionStart = richTextBoxLog.TextLength;
richTextBoxLog.SelectionLength = 0;
richTextBoxLog.SelectionColor = color;
richTextBoxLog.AppendText(text);
richTextBoxLog.SelectionColor = richTextBoxLog.ForeColor;
}
I was reading the documentation and saw that I can define custom syntax highlighting rules but is there a simple way to accomplish the same thing with AvalonEdit? Simply appending text with a specific color?
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Color different parts of a RichTextBox string
Here is an extension method that overloads the AppendText method with a color parameter: public static class RichTextBoxExtensions { public ...
Read more >Append/combine text in two cells with font color retained
I am trying to Append text from one column to other column using formula ... How can we combine text in two cells...
Read more >Append Text to RichTextBox with color - CSharp
Description. Append Text to RichTextBox with color. Demo Code. public class Main{ //for RichTextBox public static void AppendText(this System.Windows.Forms.
Read more >Changing Colors
To add a color to the background, use an attribute of the <BODY> tag known as BGCOLOR. Most newer browsers understand colors specified...
Read more >how can I append colored text to RichEditControl by code?
Hi, The AppendText method appends a plain text string to a document and returns the DocumentRange object, which you can format (e.g., change...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, it took quite a bit of digging through the code base, messing around, etc but I found a basic enough example for my situation:
(Note that I am using a ported version of AvalonEdit: AvaloniaEdit])
Thanks for all your help!
AvalonEdit has some classes that can help with implementing something like a rich text editor:
ICSharpCode.AvalonEdit.Highlighting.RichTextModel
is a data structure that can store font style/weight/color;RichTextColorizer
can apply these during rendering. This way the colors don’t need to be part of theTextDocument
. Note that you’ll manually have to hook these classes up to the editor.