Selecting a text, as someone said, may appear briefly. There are no other solutions to the problem in Windows Forms applications , but today I found a bad, working and way to solve it: you can put the PictureBox in an overlay on the RichtextBox with a screenshot if during the selection and changing the color or font, creating it after everyone reappears when operation completed.
The code is here ...
//The PictureBox has to be invisible before this, at creation //tb variable is your RichTextBox //inputPreview variable is your PictureBox using (Graphics g = inputPreview.CreateGraphics()) { Point loc = tb.PointToScreen(new Point(0, 0)); g.CopyFromScreen(loc, loc, tb.Size); Point pt = tb.GetPositionFromCharIndex(tb.TextLength); g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(pt.X, 0, 100, tb.Height)); } inputPreview.Invalidate(); inputPreview.Show(); //Your code here (example: tb.Select(...); tb.SelectionColor = ...;) inputPreview.Hide();
Better use WPF; This solution is not perfect, but it works for Winform.
user6730329 Dec 24 '16 at 9:21 2016-12-24 09:21
source share