richtextbox

How to draw border around a word in RichTextBox?

拜拜、爱过 提交于 2019-12-18 04:43:27
问题 Let's say I have 2 TextPointers. One pointing at the beginning of a word and the other at the end of the word. I would like to draw single pixel border around the word. How would I go about this? The border should be tied to the word and move with it when user types or scrolls.. I already tried TextDecorations with DrawingBrush but couldn't come up with anything usable. 回答1: I have done something similar, only underlining text in a TextBox. The principal seems to be mostly the same. Add an

How to detect if a scrollbar is or is not at the end of a richtextbox (vb.net)

假如想象 提交于 2019-12-18 04:23:22
问题 my question is as is:How to detect if a scrollbar is at or not at the end of a richtextbox? edit: when I say at the end I mean completely scrolled to the bottom, not anywhere else. 回答1: Check out the GetScrollRange and GetScrollPos API... Private Const SBS_HORZ = 0 Private Const SBS_VERT = 1 <DllImport("user32.dll")> _ Public Function GetScrollRange(ByVal hWnd As IntPtr, ByVal nBar As Integer, _ ByRef lpMinPos As Integer, _ ByRef lpMaxPos As Integer) As Boolean End Function <DllImport("user32

Highlight all searched words

 ̄綄美尐妖づ 提交于 2019-12-18 03:23:08
问题 In my RichtextBox , if I have written as below. This is my pen, his pen is beautiful. Now I search word "is" then output would be as below. All "is" should be highlighted. 回答1: What about: static class Utility { public static void HighlightText(this RichTextBox myRtb, string word, Color color) { if (word == string.Empty) return; int s_start = myRtb.SelectionStart, startIndex = 0, index; while((index = myRtb.Text.IndexOf(word, startIndex)) != -1) { myRtb.Select(index, word.Length); myRtb

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

╄→гoц情女王★ 提交于 2019-12-17 21:35:27
问题 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. 回答1: 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

Integrated Markdown WYSIWYG text editor

对着背影说爱祢 提交于 2019-12-17 21:25:07
问题 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

C# / WPF: Richtextbox: Find all Images

我与影子孤独终老i 提交于 2019-12-17 19:52:38
问题 i want a chat with inline images. The richtextbox good, because i can place images in it, but i want to send the text / images separate. -first: send the text (and place a image-placeholder in the text). -second: send the image and replace it with the placeholder. For that i need to remove all images in the richtextbox (and send them separate). But how can i find the images? And btw: Is it possible to rescale the image dependent on the width of the richtextbox? Thank you :) 回答1: To find all

Format text in Rich Text Box

☆樱花仙子☆ 提交于 2019-12-17 19:22:12
问题 How Can I format text in Rich Text Box like the following 02/11/2010 - 05:15 PM - Adam: Another test notes added on 2nd November 02/11/2010 - 05:14 PM - Z_kas: Test Notes. STAGE CHANGED TO: N Enq - Send Quote 02/11/2010 - 05:12 PM - user32: Another test notes added on 2nd November Thanks 回答1: as stated by others there is a possible duplication with an earlier question. However, please see a code snippet below. You don’t have to get the length of the text you append in order to change its

How to set RichTextBox Font for the next text to be written?

只愿长相守 提交于 2019-12-17 19:15:49
问题 I need to set the font family for the next text to be written in a RichTextBox. I tried setting that with... <RichTextBox x:Name="RichTextEditor" MaxWidth="1000" SpellCheck.IsEnabled="True" FontFamily="{Binding ElementName=TextFontComboBox, Path=SelectedItem}" FontSize="{Binding ElementName=TextSizeComboBox, Path=SelectedValue}" Width="Auto" Height="Auto" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" /> ...but it changed the whole text. I suppose that with the

Color output strings in RichTextBox

女生的网名这么多〃 提交于 2019-12-17 17:28:10
问题 I'm working on a program that calls python script and shows the output in richtextbox. I have a problem with coloring specific strings in output. For example: if the string "hey 123" will appear in the output it will colored red. Does someone have an answer? Thanks! snippet of my code: Process _cmd; delegate void setTextCallBack(string text); private void setText (string text) { if (this.richTextBox1.InvokeRequired) { setTextCallBack d = new setTextCallBack(setText); this.Invoke(d, new object

How do I change RichTextBox paragraph spacing?

断了今生、忘了曾经 提交于 2019-12-17 15:35:30
问题 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? 回答1: 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> 回答2: Using Line Height