richtextbox

RichTextBox - retain original formatting (font), even after paste

烂漫一生 提交于 2019-12-24 01:11:53
问题 I need to use a RichTextBox, not a normal textbox because of the way it keeps the caret position, from line to line. But I need to keep the text in the same font all the time even if it is pasted. At the moment I have it selecting the entire text and changing the font to the original (Lucida Console) but it look horrible when you paste into it as it flashes blue. 回答1: If you are handling the pasting programatically don't use the Paste method. Instead use Clipboard.GetDataObject().GetData

How to bottom align text in WPF RichTextBox

烈酒焚心 提交于 2019-12-24 00:43:30
问题 How I can bottom align text in RichTextBox? It seems that control doesn't support it directly. So I am looking for ways to emulate it. Ideally I would have the boundary of the control fixed and end of text aligned with the bottom. 回答1: The text comes from a ScrollViewer named PART_ContentHost inside the default control template for the TextBoxBase which is wrapped by the RichTextBox. You should override the control template and either have the ScrollViewer declare its VerticalAlignment to be

Insert a Hyperlink at a specified position in a WPF FlowDocument

*爱你&永不变心* 提交于 2019-12-24 00:37:39
问题 I'd like to insert a WPF Hyperlink element into a FlowDocument programmatically. The objective is to create a toolbar button that would take a run of text within a RichTextBox and replace it with a Hyperlink. It's the same sort of interface you see on the web for creating hyperlinks on wikis or in blogs (or on StackOverflow). I can find the TextRange of the selected text like this: TextRange tr = new TextRange( MyRichTextBox.Selection.Start, MyRichTextBox.Selection.End); And I'm attempting to

How can I save WPF RichTextBox in databse without lost links?

半世苍凉 提交于 2019-12-23 21:04:10
问题 I have a Link in Richtextbox and it works good but if I save that Richtextbox in to database and then load it that link to be deleted and I just can see the text of that Link for example my Richtextbox have bottom text: This is a link But after save and load again I just can see the text: This is a link The hyperlink created dynamically from selected text as bellow: RichTextBox.IsDocumentEnabled = true; RichTextBox.IsReadOnly = true; Run run = new Run(RichTextBox.Selection.Text); Hyperlink

jquery minimal rich textbox plugin

天涯浪子 提交于 2019-12-23 21:03:21
问题 I am looking for a very minimal jQuery rich textbox plugin for a web app I am working on. The user will only need to see the 'textbox', and not any toolbars as all of the rich formatting will be coded depending on what they type. I have attempted to create my own with an iframe, but there are problems. One of them being when wrapping strings in divs, the caret is moved to the beginning and it can't be moved inside the div without clicking. http://jsfiddle.net/DVjYa/ This is a problem because

Append New Paragraph To RichTextBox

徘徊边缘 提交于 2019-12-23 19:10:13
问题 I need to programmatically add a new paragraph to a RichTextBox control (just like pressing Enter). Using the code below, it does add a new paragraph but: It deletes all the existing text in the control The insertion point remains in the first line and doesn't move to the second newly created line It only seems to add a new paragraph once, i.e. if I run the code a second time, a third paragraph isn't created FlowDocument flowDoc= rtbTextContainer.Document; Paragraph pr = new Paragraph();

C#: Changing font style of WinForm RichTextBox without selecting the text

别来无恙 提交于 2019-12-23 17:31:27
问题 I am using a RichTextBox in my code where I show syntax-highlighted code. Now, on every keystroke, I have to re-parse all the tokens and re-color them all over again. But the only way to color individual words in a WinForm richtextbox is to select those words one by one and color them using SelectionFont. But if the user is typing really fast, there is a very noticeable flickering caused by my selecting individual words (selected words have that Windows blue-background thing and that is

Append text and image in RichTextBox

北城以北 提交于 2019-12-23 17:27:32
问题 For Append Text private void AddText(string text) { string[] str = text.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); if (str.Length == 2) { richTextBox1.DeselectAll(); richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont, FontStyle.Bold); richTextBox1.AppendText(Environment.NewLine + str[0] + ";"); richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont, FontStyle.Regular); richTextBox1.AppendText(str[1]); } } For Append Image Image image = Image

Drag and drop in read only rich text box

喜你入骨 提交于 2019-12-23 15:41:14
问题 I am trying implement drag and drop feature in RichTextBox (windows common control). It works fine using the code shown below. However, the drag drop event is not getting triggered when I set the ReadOnly property to true. Is there anything that I am missing? or is that the right behaviour ? Please advice. private void rtb_dragdrop(object sender, DragEventArgs e) { Console.WriteLine("Test"); } private void rtb_dragenter(object sender, DragEventArgs e) { e.Effect = DragDropEffects.Copy; } 回答1:

How to Append RTF Text in RichTextBox, Win C#

久未见 提交于 2019-12-23 14:59:07
问题 I have a RichTextBox in Win C#, and I want to append some new text with Bold effect in RichTextBox. So how can i do this. I tried string str = richTextBox.Rtf; //my logic str+= @"\rtf1\ansi Adding Some \b Text\b0.}"; // Now Appending richTextbox.AppendText(str); But its not showing the correct. My Output before This is First Word. and i want output like This is First Word. Adding Some Text . So how can I do this? 回答1: The following function takes a reference to a RichTextBox, along with some