richtextbox

Show LineNumbers from the RichTextBox in WPF

瘦欲@ 提交于 2019-11-29 04:32:21
问题 I found an example, how to show the LineNumbers from a RichTextBox in Windows Forms. http://www.codeproject.com/Articles/38858/Line-Numbers-for-RichText-Control-in-C Have somebody an example for it in WPF ? Edit: Does someone have work with AvalonEdit, because he wanted to show LineNumbers in his Programm and can help me by my Problem. 回答1: I thought just to add a simple solution... Avalon (Download) has been mentioned, here is how to do row lines with it: <avalon:TextEditor ShowLineNumbers=

RichTextBox cannot display Unicode Mathematical alphanumeric symbols

限于喜欢 提交于 2019-11-29 04:26:01
I cannot get WinForms RichTextBox display some Unicode characters, particularly Mathematical alphanumeric symbols (but the problem is most probably not limited to those). Surprisingly the same characters can display in a plain or multiline TextBox using the same (default) font. Even if I change the font to for example "Arial" or "Lucida", I get the same results. The screenshot is from Windows 10, but I'm getting the same results on Windows 7. The example shows ascii small a-d followed by mathematical italic sans-serif small alpha-delta . I'm using Visual Studio 2017 and .NET 4.6.1. A trivial

How to get cursor position or location from RichTextArea in GWT?

点点圈 提交于 2019-11-29 02:23:35
I want to get cursor position or the location from RichTextArea. I do not know how to get current cursor position Without any mouse event. e.g. TextArea has method getCursorPos(), but RichTextArea does not have method like TextArea. Anyone have any idea? Please help me... Thanks in advance... Andrei Volgin If you you want to insert something in the RichTextArea at the cursor position, you can do it with the formatter: RichTextArea.Formatter formatter = richText.getFormatter(); formatter.insertHTML("My text is inserted at the cursor position"); To find a cursor position using JavaScript, try

WPF RichTextBox with no width set

左心房为你撑大大i 提交于 2019-11-28 21:14:38
I have the following XAML code: <Window x:Class="RichText_Wrapping.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1"> <Grid> <RichTextBox Height="100" Margin="2" Name="richTextBox1"> <FlowDocument> <Paragraph> This is a RichTextBox - if you don't specify a width, the text appears in a single column </Paragraph> </FlowDocument> </RichTextBox> </Grid> ... If you create this window in XAML, you can see that when you don't specify a width for the window, it wraps the text in a single column, one letter

Storing data of rich text box to database with formatting

笑着哭i 提交于 2019-11-28 17:06:45
I am new at wpf and I want to store the data of the rich text box along with its formatting (Italic, colored, Bold..) into a database (Mysql). currently when i save the data, formatting is ignored. in addition, it shows all the text in the same line when i load it back to the rich text box from the database. Looking forward to your help and suggestions! public void save() { MySqlConnection conn = new MySqlConnection(connString); MySqlCommand command = conn.CreateCommand(); string richText = new TextRange(rt1.Document.ContentStart, rt1.Document.ContentEnd).Text; string s = WebUtility.HtmlEncode

Integrated Markdown WYSIWYG text editor

时光毁灭记忆、已成空白 提交于 2019-11-28 15:10:37
In looking for a straightforward WYSIWYG editor for Markdown code, I am not finding a comparible UI to that of CkEditor, TinyMCE, ect. Specifically, the Markdown "WYSIWYG" editors that are often recommended (such as posts like this ) are not pure WYSIWYG editors in the sense that users either still write raw Markdown ( MarkItUp ) or go to the other extreme of having in-line editing without standard controls ( Hallo ). I need something in-between. I'm looking for a Markdown editor that looks and functions like a stripped down CkEditor text box, and that accepts and outputs Markdown. There

Highlighting a line in a RichTextBox1, line number = a variable

耗尽温柔 提交于 2019-11-28 14:47:12
I have a variable, lets say it = 5, and then I would like the line number 5 to be highlighted "blue" in my RichTextBox1. is that possible at all? Or should I use something like a ListBox, DataGridView etc. TaW This will highlight the text in a given line in a RichTextBox if WordWrap is off: void highLightALine(RichTextBox rtb, int line, Color hiLight) { int i1 = rtb.GetFirstCharIndexFromLine(line); int i2 = rtb.GetFirstCharIndexFromLine(line + 1); if (i2 < 0) i2 = rtb.Text.Length; rtb.SelectionStart = i1; rtb.SelectionLength = i2 - i1; rtb.SelectionBackColor = hiLight; } Note that if WordWrap

how to add a character at the beginning of each line in Richtextbox

♀尐吖头ヾ 提交于 2019-11-28 14:22:28
I am doing an app that adds a certain character for each selected line if you click the button. for example "//" in each line in a Richtextbox and colored the text into red, it is like the function of comment out in visual studio i tried this but it did'nt work private void toolStripButton1_Click(object sender, EventArgs e) { int firstCharPosition = richTextBox1.GetFirstCharIndexOfCurrentLine(); int lineNumber = richTextBox1.GetLineFromCharIndex(firstCharPosition); int lastCharPosition = richTextBox1.GetFirstCharIndexFromLine(lineNumber + 1); if (richTextBox1.SelectionLength > 0) {

removing RichTextBox lines while keeping the colour of remaining lines in C#

萝らか妹 提交于 2019-11-28 14:02:40
Consider a RichTextBox which has 400 lines and includes a number of words and lines in diffident colours. Is it possible to remove the first 100 lines of this text box, while the colour of remaining words are reserved. Currently, I am using the below code to remove lines, but It is not able to keep colours. if (rtb.Lines.Count() > 400) rtb.Lines = rtb.Lines.Skip(100).ToArray(); Hans Passant Use the SelectionText property. First select the lines you want to remove, then remove them by setting SelectionText to an empty string. Like this: richTextBox1.SelectionStart = 0; richTextBox1

RichTextBox and UserPaint

泄露秘密 提交于 2019-11-28 13:49:19
I'm trying to paint over a RichTextBox but the only way I can do it is by calling OnPaint/OnPaintBackground . The problem is the OnPaint or OnPaintBackground aren't called unless the "UserPaint" flag is on, but when this flag is on - the text itself won't be painted! how can I solve this? This is the code I use to ensure OnPaint is called after RichTextBox has handled the painting itself first: class MyRichTextBox: RichTextBox { private const int WM_PAINT = 15; protected override void WndProc(ref System.Windows.Forms.Message m) { base.WndProc (ref m); if (m.Msg == WM_PAINT && !inhibitPaint) {