richtextbox

vb.net - Multicolor RichTextBox

人盡茶涼 提交于 2019-11-28 01:31:48
问题 I would like to make a line of text in my richtextbox multicolor. I have tried various implementations provided on the web and read up on SelectedText and other topics but can't seem to get it to work the way I would like to. Here is what I have so far RichTextBox1.Text = "This is black " RichTextBox1.SelectionFont = New Font("Microsoft Sans Serif", 8.25, FontStyle.Bold) RichTextBox1.SelectionColor = Color.Green RichTextBox1.SelectedText = "[BOLD GREEN]" RichTextBox1.Text = RichTextBox1.Text

making a simple search function, making the cursor jump to (or highlight) the word that is searched for

余生颓废 提交于 2019-11-28 01:28:31
问题 I have now used way too long time, trying to figure out a problem, which I didn't think would be that hard. Here is the deal: I am writing a small application using C# and WPF. I have a RichTextBox containing a FlowDocument. I have added a small textbox and a button below my richtextbox. The user then types in the word he/she wishes to search for, and presses the button. The richtextbox will then jump to the first occurrance of that word. it is enough that it just jumps to the correct line -

Clicking HyperLinks in a RichTextBox without holding down CTRL - WPF

荒凉一梦 提交于 2019-11-28 00:53:33
I have a WPF RichTextBox with isReadOnly set to True . I would like users to be able to click on HyperLinks contained within the RichTextBox, without them having to hold down Ctrl . The Click event on the HyperLink doesn't seem to fire unless Ctrl is held-down, so I'm unsure of how to proceed. I found a solution. Set IsDocumentEnabled to "True" and set IsReadOnly to "True". <RichTextBox IsReadOnly="True" IsDocumentEnabled="True" /> Once I did this, the mouse would turn into a 'hand' when I hover over a text displayed within a HyperLink tag. Clicking without holding control will fire the 'Click

Open file in rich text box with C#

随声附和 提交于 2019-11-28 00:30:47
问题 This question have been answered. I recommend sumit_programmers solution below. For now, I've removed my code, thinking it's more confusing than helpful. When I've developed it a bit further, perhaps I'll post my code here, with some comments. You may also be interested in the answer to the question Save text from rich text box with C#. There is an answer that reminds of the accepted answer to this question. The code should work, but it's written by me, so there may be some errors or missing

Reading PDF in C# [closed]

廉价感情. 提交于 2019-11-27 23:50:54
I want to read and display the contents of the PDF files into my RichtextBox. I am using windows application C#. Is it possible? What is the way to do it? You can use Adobe PDF IFilter Library to convert a PDF document to text. Also see an example on the CodeProject iTextSharp is another alternative PDF library for .NET. Since PDF is an binary format you'll have to use a pdf-library like pdflib in order to read pdf-files. pdfLib You should checkout PDFSharp library and they have preview component, where else extracting text and showing them in RichTextBox could be little bit of more work, but

How to 'align' text in RichTextBox C#?

泪湿孤枕 提交于 2019-11-27 23:36:15
问题 How do I align the text in a RichTextBox? Basically, the RTB contains: "--testing" "--TESTING" "TESTING--" "testing--" Which all have the same number of characters, but have different alignments. How can I align them properly? Im fairly new to C# and confused since it aligned properly in Java's TextArea. Thank you! 回答1: You would have to change the font to a monospaced font, like Courier. This behavior you're showing is standard with most fonts, as not all characters are the same width. 回答2:

How to access properties of a usercontrol in C#

℡╲_俬逩灬. 提交于 2019-11-27 23:31:05
I've made a C# usercontrol with one textbox and one richtextbox. How can I access the properties of the richtextbox from outside the usercontrol. For example.. if i put it in a form, how can i use the Text propertie of the richtextbox??? thanks Cleanest way is to expose the desired properties as properties of your usercontrol, e.g: class MyUserControl { // expose the Text of the richtext control (read-only) public string TextOfRichTextBox { get { return richTextBox.Text; } } // expose the Checked Property of a checkbox (read/write) public bool CheckBoxProperty { get { return checkBox.Checked;

How to append \\line into RTF using RichTextBox control

扶醉桌前 提交于 2019-11-27 22:06:57
When using the Microsoft RichTextBox control it is possible to add new lines like this... richtextbox.AppendText(System.Environment.NewLine); // appends \r\n However, if you now view the generated rtf the \r\n characters are converted to \par not \line How do I insert a \line control code into the generated RTF? What does't work: Token Replacement Hacks like inserting a token at the end of the string and then replacing it after the fact, so something like this: string text = "my text"; text = text.Replace("||" "|"); // replace any '|' chars with a double '||' so they aren't confused in the

How can I use NLog's RichTextBox Target in WPF application?

有些话、适合烂在心里 提交于 2019-11-27 21:45:01
How can I use RichTextBox Target in WPF application? I don't want to have a separate window with log, I want all log messages to be outputted in richTextBox located in WPF dialog. I've tried to use WindowsFormsHost with RichTextBox box inside but that does not worked for me: NLog opened separate Windows Form anyway. If you define a RichTextBoxTarget in the config file, a new form is automatically created. This is because NLog initializes before your (named) form and control has been created. Even if you haven't got any rules pointing to the target. Perhaps there is a better solution, but I

Bind text with links to RichTextBox

别等时光非礼了梦想. 提交于 2019-11-27 21:38:43
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/ Nazar Grynko I implemented what I need using System; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Text.RegularExpressions; using System.Windows.Media; namespace NazarGrynko.UI.Controls {