richtextbox

Wrapping Text in a rich textbox, but not word wrapping it

拥有回忆 提交于 2019-12-01 06:00:57
I have a Windows Form with a Rich Textbox control on the form. What I want to do is make it so that each line only accepts 32 characters of text. After 32 characters, I want the text to flow to the next line (I do NOT want to insert any carriage returns). The WordWrap property almost does this, except that it moves all the text entered, up to the last space in the text and moves it all. I just want to neatly wrap the text right after 32 characters. How can I do this? I'm using C#. Ok, I have found a way to do this (after a lot of googling and Windows API referencing) and I am posting a

How to show cursor in unfocused WinForms TextBox/RichTextBox?

折月煮酒 提交于 2019-12-01 05:40:26
问题 I need to show cursor in RichTextBox control in WinForms application even when it's not in focus. How can I do this? I found only the way for WPF ( How to keep WPF TextBox selection when not focused?) 回答1: You can use WinAPI .. [DllImport("user32.dll", EntryPoint = "ShowCaret")] public static extern long ShowCaret(IntPtr hwnd); [DllImport("user32.dll", EntryPoint = "HideCaret")] public static extern long HideCaret(IntPtr hwnd); and call ShowCaret whenever you want 回答2: You can't set focus to

Fastest way to append text to a richtextbox?

谁说我不能喝 提交于 2019-12-01 05:12:16
问题 I have a application with a RichTextBox control where a procedure is adding text almost all the time: RichTextBox1.Text += vbNewLine & "Title: " & AlbumName RichTextBox1.Text += vbNewLine & "Genre: " & AlbumGenre RichTextBox1.Text += vbNewLine & "Year : " & AlbumYear RichTextBox1.Text += vbNewLine & "Url : " & AlbumLink ' The slow thing I think is here: RichTextBox1.SelectionStart = RichTextBox1.Text.Length RichTextBox1.ScrollToCaret The problem is when the richtextbox has about more than 50

Determining the selected InlineUIContainer in a WPF RichTextBox

浪子不回头ぞ 提交于 2019-12-01 04:46:01
问题 I'd like to determine if there is an InlineUIContainer (or BlockUIContainer) at the current Caret position in a WPF RichTextBox. Currently I have a RichTextBox as follows; <RichTextBox SelectionChanged="RichTextBox_SelectionChanged"> <FlowDocument> <Paragraph> <Run>Some text before</Run> <InlineUIContainer> <Label>I am a label</Label> </InlineUIContainer> <Run>Some text after</Run> </Paragraph> </FlowDocument> </RichTextBox> In the SelectionChanged event I have tried using; rtf.CaretPosition

Change font of text in richtextbox

故事扮演 提交于 2019-12-01 04:41:11
My text is in a richtextbox: <Parag1 Level="One"> First text of parag1. Second text of parag1. </Parag1> <Parag2 Level="Two"> First text of parag2. Second text of parag2. </Parag2> <Parag3 Level="Footer"> First text of parag3. Second text of parag3. </Parag3> <Parag4 Level="Three"> First text of parag4. Second text of parag4. </Parag4> I want change color font & text color of text : 1- For tags -> font name = Tahoma , size= 10,color=red Example : <Parag1 Level="One"> Or </Parag1> 2- For Text between tags that tag's level is not Footer -> font name = Arial , size= 12,color=black Example : First

C# How can I paste formatted text from clipboard to the RichTextBox

落爺英雄遲暮 提交于 2019-12-01 04:38:09
问题 I added context menu to the richboxtext with only one function "paste". What code will paste my clipboard content (e.g. copied from Microsoft Word) to the richboxtext form? I tried with: private void PasteToolStripMenuItem_Click_1(object sender, EventArgs e) { richTextBox1.Text = Clipboard.GetText(); } but it pastes non-formatted text. How can I paste text with the formatting? 回答1: Got it! Just specificy the format: richTextBox1.Text = Clipboard.GetText(TextDataFormat.Rtf); UPDATE This will

Current line and column numbers in a RichTextBox in a Winforms application

房东的猫 提交于 2019-12-01 04:29:41
How do I get the current line and column numbers in a RichTextBox in a Winforms application? NOTE Folks, I just want a simple solution, if it's available by someone and he's willing to share it with us, and not links to do research! Just give me some code please! Otherwise, I'll have to buy a control... SwDevMan81 For row and column, check out the Richer RichTextBox project. It is an extended version of the RichTextBox which supports the row and column numbers. The code from the article: this.rtb.CursorPositionChanged += new System.EventHandler(this.rtb_CursorPositionChanged); this.rtb

transparent richTextBox

随声附和 提交于 2019-12-01 04:26:06
how can I make my richtext box transparent I want this cuz I am trying to put a text on top of a graphic image (which is the background of my form). That is why I wanted the richTextBox to be transparent, I am using .NET ,c# and in a windows form application There is no such thing as true transparency in a WinForms Control. Transparent mode inherits the default background of its parent. The way I have worked around it in the past has been to use the OnPaint event and then use the Graphics.DrawString method to position the text where I want it. I know this answer is very late, but I hope it

Show pdf inside silverlight application. PDF to XAML

本秂侑毒 提交于 2019-12-01 04:24:15
问题 I need to create silverlight application where customer will see some pdf files. PDF files have to be inside silverlight control and not rendered as images (customer wants to select text) For this purposes i need some free libriaries or code to convert pdf file to xaml (or just open pdf so i can convert it to xaml). Which library can read pdf and help me to convert data to xaml? Can I read somehow pdf file and write custom convertation tool? I saw iTextSharp. Is this library can read pdf and

Using GetLineStartPosition to get the end of a line in WPF RichTextBox

半腔热情 提交于 2019-12-01 04:17:37
问题 A bit of background. I would like to be able to process text for the line that the caret is on in a WPF RichTextBox. Please see my earlier question about the TextPointer class: How to keep track of TextPointer in WPF RichTextBox?. I know how to get the TextPointer at the start of the current line by using GetLineStartPosition with 0 as the argument but would now like to get the TextPointer at the end of the line. It was suggested in my previous question that this is possible using the