richtextbox

From RichTextBox to text files, line after line

你说的曾经没有我的故事 提交于 2019-11-29 09:01:34
I have trouble with saving file from Richtextbox to text file. My richtextbox looks like this; ABC ... SDE ... KLO ... After i saved it looks like this: ABC ... SDE ... KLO ... But i want the same like richtextbox line after lines. What did i do wrong? if (saveFileDialog2.ShowDialog() == DialogResult.OK) { StreamWriter sw = File.CreateText(saveFileDialog2.FileName); sw.WriteLine(richTextBox1.Text); sw.Flush(); sw.Close(); //File.WriteAllText(saveFileDialog2.FileName, str); } You are probably getting this because you are trying to save richTextBox1.Text (the whole text) in one line only using

Saving RichTextBox FlowDocument to image

。_饼干妹妹 提交于 2019-11-29 08:31:33
i'am making a programm where i want my RichTextBox content (text+images) to be saved as an image (jpg/png). I tried to use this solution but i get only black filled image from SaveUIAsGraphicFile() I also tried to create FormattedText from my rtb control, printing it works fine, but its not possible to insert images in there. Maybe it is possible to print FlowDocument somehow? You could use something like the following method to create a bitmap from a FlowDocument: public BitmapSource FlowDocumentToBitmap(FlowDocument document, Size size) { document = CloneDocument(document); var paginator = (

Printing RichTextBox

天涯浪子 提交于 2019-11-29 08:08:42
I am making a simple WinForms App and I wanted to allow the user to print the Text from RichTextBox. I followed MSDN link then.. And it works for a real printer (by real I mean that one I can touch:) ) But what if I want use some kind of PDF Printer? Then I must say it works when only one page is printed. Every next page is being printed on the same, first page , which means the text is being overprinted. This is obvious, but what I can do do force PDF Printer to create a new Page? This is my code: private PrintDocument docToPrint; private string stringToPrint; public mainForm() {

Change style of selected Text in RichTextBox

天涯浪子 提交于 2019-11-29 08:08:00
How can I change styles (such as Font, FontSize, Brush) of selected Text in RichTextBox ? Update : Let's say I've a RichTextBox and a Toolbar. User comes and select text inside the RichTextBox box and change the font size from toolbar. I want to change style of selected text. MethodMan WPF if (this.TextEditor.Selection.IsEmpty) this.TextEditor.CurrentFontFamily = SelectedFont; else this.TextEditor.Selection.ApplyPropertyValue(TextElement.FontFamilyProperty, SelectedFont); or another WPF Example private void ChangeTextProperty(DependencyProperty dp, string value) { if (mainRTB == null) return;

C# RichTextBox Remove Custom SelectionBackColor

主宰稳场 提交于 2019-11-29 08:04:07
After having done some research, I believe I am asking the same question as Remove richtextbox SelectionBackColor . I have encountered the same issue, but I believe the answers in that thread were insufficient as the question was not clearly explained. Please see below: In a RichTextBox , how do I remove a custom BackColor from some, but not all, of the text ( SelectionBackColor ) so that it assumes the BackColor of the control even if that BackColor changes in the future? I have a method that highlights some text and changes its BackColor using SelectionBackColor . I have another method that

vb.net - Multicolor RichTextBox

僤鯓⒐⒋嵵緔 提交于 2019-11-29 07:54:51
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 + " black again" The colors I want are stated as the text. What happens is: the entire line turns green

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

試著忘記壹切 提交于 2019-11-29 07:36:28
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 - it can also select, highlight or place the cursor by the word - anything will do, as long as the

Disabling RichTextBox autoscroll

我与影子孤独终老i 提交于 2019-11-29 07:32:19
I am using RichTextBox control for displaying application logs. I am updating control once a second with a few calls of RichTextBox::AppendText method. What is really annoying for me is that cursor keeps scrolling to the last line of text. Its very uncomfortable in situation when user needs to analyze logs that are at the beginning. I have tried following solution to my problem: int pos = tb_logs.SelectionStart; tb_logs.AppendText("log message"); tb_logs.SelectionStart = pos; This does not go to the core of problem because control is being periodically redrawed which is very distracting. Is

How to 'align' text in RichTextBox C#?

ⅰ亾dé卋堺 提交于 2019-11-29 06:07:08
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! 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. You want to use the RichTextBox.SelectionAlignment property. For instance if you want the whole textbox centered,

Extended WPF Toolkit - using the RichTextBoxFormatBar

不打扰是莪最后的温柔 提交于 2019-11-29 05:05:21
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 WPF so I'm know it's something I'm not picking up on rather than a bug, can anyone tell me what I'm