Public ColouredText(string text, Color foreground, Color background) I prepared a little helper for the RichTextBox control which makes it very easy to generate colored text on the screen: using Int jx = s.IndexOf(StartTag, ix, StringComparison.CurrentCultureIgnoreCase) static void HighlightPhrase(RichTextBox box, string StartTag, string EndTag, string ControlTag, Color color1, Color color2) I created this Function after researching on the internet since I wanted to print an XML string when you select a row from a data grid view. )īetter is to use WPF this solution isn't perfect, but for Winform it works. Your code here (example: tb.Select(.) tb.SelectionColor =. G.FillRectangle(new SolidBrush(Color.Red), new Rectangle(pt.X, 0, 100, tb.Height)) Point pt = tb.GetPositionFromCharIndex(tb.TextLength) ![]() Point loc = tb.PointToScreen(new Point(0, 0)) Using (Graphics g = inputPreview.CreateGraphics()) inputPreview variable is your PictureBox ![]() The PictureBox has to be invisible before this, at creation In Windows Forms applications there is no other solutions for the problem, but today I found a bad, working, way to solve: you can put a PictureBox in overlapping to the RichtextBox with the screenshot of if, during the selection and the changing color or font, making it after reappear all, when the operation is complete.Ĭode is here. Selecting text as said from somebody, may the selection appear momentarily. Public static List GetAllWordsIndecesBetween(string intoText, string fromThis, string toThis,bool withSigns = true) List ls = GetAllWordsIndecesBetween(rtb.Text, startWord, endWord, true) ![]() It`s work for me! I hope it will be useful to you! public static RichTextBox RichTextBoxChangeWordColor(ref RichTextBox rtb, string startWord, string endWord, Color color)
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |