richtextbox

Bind text with links to RichTextBox

一个人想着一个人 提交于 2019-11-26 20:45:23
问题 I need to bind text which may contain hyperlinks to RichTextBox so it could show text as normal text and links as hyperlinks. For example I have following text: Join us on social networks http://www.facebook.com/ I want that links in a text be hyperlinks so the result in RichTextBox would be like this: Join us on social networks http://www.facebook.com/ 回答1: I implemented what I need using System; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using

How do I maintain RichText formatting (bold/italic/etc) when changing any one element?

不羁的心 提交于 2019-11-26 20:28:00
问题 I have a rich text box that may contain a string that has elements of bold, italics, or even different fonts and sizes. If I select the entire string, including all of the differences, how can I "Bold" that string without converting the entire string to the generic font with just a "bold" attribute? For example: I want to turn "This is some text " into " This is some text " Note that "is some" remained italicized and "text" remained a different font. What I currently have is quite simplistic:

Select Range of Text in WPF RichTextBox (FlowDocument) Programmatically

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 20:25:12
问题 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);

RichTextBox Selection Highlight

妖精的绣舞 提交于 2019-11-26 18:27:19
问题 Is there a possibility that after selection made by user, every selected letter displays it's original color? And not always white as it's by default? I want to achieve something like that which you can see in wordpad. instead of which you see in RichTextBox . 回答1: You can use the latest version of RichTextBox that is RICHEDIT50W , to do so you should inherit from standard RichTextBox and override CreateParams and set the ClassName to RICHEDIT50W : Code using System; using System

Create guitar chords editor in WPF (from RichTextBox?)

隐身守侯 提交于 2019-11-26 18:13:43
问题 Main purpose of application I'm working on in WPF is to allow editing and consequently printing of songs lyrics with guitar chords over it. You have probably seen chords even if you don't play any instrument. To give you an idea it looks like this: E E6 I know I stand in line until you E E6 F#m B F#m B think you have the time to spend an evening with me But instead of this ugly mono-spaced font I want to have Times New Roman font with kerning for both lyrics and chords (chords in bold font).

Changing font for richtextbox without losing formatting

大兔子大兔子 提交于 2019-11-26 17:26:45
问题 How to change the font of all the contents of a richtextbox without losing formatting? I am trying to use rtb.SelectAll(); rtb.SelectionFont = new Font(fontName,...); but the font constructor has to take besides the font type either the font style (bold, italics, ...) or font size. So using this would change the style/size of all the content of the richtextbox. Of course the same applies for any selection in the richtextbox. 回答1: This is a RichTextBox that I have used in the past. It's

Rich Text Box how to highlight text block

微笑、不失礼 提交于 2019-11-26 17:25:54
问题 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. 回答1: I think you are looking for ScintillaNET. On the other hand if you want to do

C# - Loading a large file into a WPF RichTextBox?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 17:25:54
问题 I need to load a ~ 10MB range text file into a WPF RichTextBox, but my current code is freezing up the UI. I tried making a background worker do the loading, but that doesnt seem to work too well either. Here's my loading code. Is there any way to improve its performance? Thanks. //works well for small files only private void LoadTextDocument(string fileName, RichTextBox rtb) { System.IO.StreamReader objReader = new StreamReader(fileName); if (File.Exists(fileName)) { rtb.AppendText(objReader

RichTextBox Newline Conversion?

99封情书 提交于 2019-11-26 16:45:52
问题 I'm using a WinForms RichTextBox. It appears that when the RichTextBox is on a form, \r\n gets converted to \n . Here's a test: I have two rich text boxes. One is richTextBox1 , which is placed on the form: this.richTextBox1 = new System.Windows.Forms.RichTextBox(); this.SuspendLayout(); // // richTextBox1 // this.richTextBox1.Location = new System.Drawing.Point(37, 12); this.richTextBox1.Name = "richTextBox1"; this.richTextBox1.Size = new System.Drawing.Size(100, 96); this.richTextBox1

Prevent Autoscrolling in RichTextBox

限于喜欢 提交于 2019-11-26 16:37:04
问题 I have a readonly data logging window that I implemented using the RichTextBox control. I'd like to be able to disable the autoscrolling that happens when the user clicks in the control so that the user can select a specific log for copy/paste operations or whatever. However, as soon as the user clicks in the RichTextBox, it automatically scrolls to the bottom, making this difficult. Anyone know a way to override this behavior? Thanks! 回答1: The RichTextBox control automatically scrolls to the