richtextbox

Select Range of Text in WPF RichTextBox (FlowDocument) Programmatically

Deadly 提交于 2019-11-27 20:37:54
I have this WPF RichTextBox and I want to programmatically select a given range of letters/words and highlight it. I've tried this, but it doesn't work, probably because I'm not taking into account some hidden FlowDocument tags or similar. For example, I want to select letters 3-8 but 2-6 gets selected): var start = MyRichTextBox.Document.ContentStart; var startPos = start.GetPositionAtOffset(3); var endPos = start.GetPositionAtOffset(8); var textRange = new TextRange(startPos,endPos); textRange.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(Colors.Blue)); textRange

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

孤街浪徒 提交于 2019-11-27 19:31:20
问题 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(); 回答1: Use the SelectionText property. First select the lines you want to remove, then remove them by setting

RichTextBox and UserPaint

家住魔仙堡 提交于 2019-11-27 19:30:17
问题 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? 回答1: 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

Extended WPF Toolkit - using the RichTextBoxFormatBar

社会主义新天地 提交于 2019-11-27 18:51:22
问题 I've been trying to use the Extended WPF Toolkit so that I can make use of the RichTextBoxFormatBar but I seem to be going round in cirlces. Despite trying several examples on here and other sites I keep getting the same error messages: The attachable property 'FormatBar' was not found in type 'RichTextBoxFormatBarManager'. The type 'toolkit:RichTextBoxFormatBar' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built. I'm new to

Insert Image at Cursor Position in Rich Text box

被刻印的时光 ゝ 提交于 2019-11-27 18:50:50
问题 I know there are various questions like this but i'm asking because i couldn't understand all the answers give. I have RichTextBox and i want the user to be able to insert an image at the current cursor position. I have tried using the Clipboard to set the Image and then pasting it in the rich textbox. This works but i've been told its bad practice as it change data in a cliboard without notifying the user. This is what i have tried private bool CheckIfImage(string filename) { if (filename

How do I change RichTextBox paragraph spacing?

为君一笑 提交于 2019-11-27 18:40:32
I am using a RichTextBox in WPF, and am trying to set the default paragraph spacing to 0 (so that there is no paragraph spacing). While I could do this in XAML, I would like to achieve it programmatically if possible. Any ideas? I did it with style (pun indented) <RichTextBox Margin="0,51,0,0" Name="mainTextBox" > <RichTextBox.Resources> <Style TargetType="{x:Type Paragraph}"> <Setter Property="Margin" Value="0"/> </Style> </RichTextBox.Resources> </RichTextBox> Using Line Height RichTextBox rtb = new RichTextBox(); Paragraph p = rtb.Document.Blocks.FirstBlock as Paragraph; p.LineHeight = 10;

RichTextBox cannot display Unicode Mathematical alphanumeric symbols

*爱你&永不变心* 提交于 2019-11-27 18:23:09
问题 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

What is the best rich textarea editor for jQuery? [closed]

百般思念 提交于 2019-11-27 16:42:27
Something like this one on the Stackoverflow site would be nice! Or something non-jQuery that doesn't conflict with jQuery $() tags would be great. Chris S I'm surprised nobody has mentioned markitup : markItUp! is a JavaScript plugin built on the jQuery library. It allows you to turn any textarea into a markup editor. Html, Textile, Wiki Syntax, Markdown, BBcode or even your own Markup system can be easily implemented. For me markitup is an excellent editor. It does rich text as a markup editor and allows you to use different standards: html, wiki, UBB, etc... It also allows plugins very

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

爷,独闯天下 提交于 2019-11-27 16:42:19
问题 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... 回答1: 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

Rich Text Box how to highlight text block

三世轮回 提交于 2019-11-27 16:13:16
I need a certain portion of my text in RTB to be highlighted not in the sense of changing the font style/color, but in the sense of making a block selection with a particular color. This is similar to how Visual Studio highlights a line during debug mode. How can I accomplish this feature using RTB or rather, is it even possible? If it isn't possible, I'd like to hear another way of performing the above task. I think you are looking for ScintillaNET . On the other hand if you want to do this by yourself in RTB then you can do it by first finding the lineNumber using TextBoxBase.Lines property.