richtextbox

WPF: Allow user to resize images in RichTextBox

旧街凉风 提交于 2019-12-04 13:24:28
问题 Is there a method within the RichTextBox control in WPF to allow for the user to resize inserted images, or do you have to devise your own method for this. What I'm trying to achieve is shown below, a screenshot of a WordPad doing what I want: Notes: Reading the RTF file as plain text I find that the control tags related to image size is \picscalex100 and \picscaley100 (where 100 denotes scaled to 100%). So yeah, is there a proper way or trick to this? Any advice on how to go about

Copy selected text from RichTextBox

寵の児 提交于 2019-12-04 12:11:07
I have searched around on the net but I cannot find a method of copying/cutting/pasting selected text from a RichTextBox . Even MSDN does not have an answer. The code they provide does not work: Copy() only appears to work on TextBoxes, not RichTextBoxes. If you're using .NET 3.0 and above you can always use Clipboard.SetText() I found it useful to use the Clipboard when I want everything in the richTextBox without having to select everything first or when I need to change the string: string text = "Summary:" + Environment.NewLine + this.richTextBoxSummary.Text; Clipboard.SetText(text); if I

Check if selected text on richtextbox is not all bold or mixed [C#] [duplicate]

杀马特。学长 韩版系。学妹 提交于 2019-12-04 11:37:21
This question already has an answer here: Check if selected text on richtextbox is all bold or not 1 answer How to check if selected text on richtextbox that its chars is not all bold. For example: notbold bold notbold ← this is mixed. Im not all bold ← this is not all bold This is the code I have made, it checks selected text on richtextbox whether the text contains some bolded text or not. its slow because its checking the char one by one using Selection.Start to Selection.Length and check if bold. If I use richTextBox1.SelectionFont.Bold it will return false because its not all bold, that

WPF RichTextBox TextChanged event - how to find deleted or inserted text?

五迷三道 提交于 2019-12-04 09:39:29
While creating a customized editor with RichTextBox, I've face the problem of finding deleted/inserted text with the provided information with TextChanged event. The instance of TextChangedEventArgs has some useful data, but I guess it does not cover all the needs. Suppose a scenario which multiple paragraphs are inserted, and at the same time, the selected text (which itself spanned multiple paragraphs) has been deleted. With the instance of TextChangedEventArgs, you have a collection of text changes, and each change only provides you with the number of removed or added symbols and the

How do online rich text editors work?

落花浮王杯 提交于 2019-12-04 08:58:48
问题 I was wondering how online rich text editors maintain the formatting when you paste text from a webpage or document. A standard textarea box only takes text while these WYSIWYG editors seem to use a DIV. How does it work? 回答1: Online rich text editors use contentEditable or designMode to take advantage of the browser's native support for HTML editing. When you paste into a contentEditable or designMode element, the browser puts HTML directely into the element. Try it yourself by pasting into

Strange shift when Selecting text in richtext box v5 that contains hyperlinks

点点圈 提交于 2019-12-04 07:37:37
When I use the RichTextBox.Select(int start, int length) function to select text in a rich text box that contains hyperlinks, there is some shift in the selection when I try to select any text that is after the hyperlink. When I remove the hyperlink, the selection works properly. Edit: I use RichTextBox 5 (the default in Visual Studio is version 4) public class RichText50W : RichTextBox { [DllImport("kernel32.dll", CharSet = CharSet.Auto)] static extern IntPtr LoadLibrary(string lpFileName); protected override CreateParams CreateParams { get { CreateParams prams = base.CreateParams; if

Changing string colour

为君一笑 提交于 2019-12-04 06:46:48
问题 Okay, so this is a carry on from my last question, but I have the code: private void btnTrans_Click(object sender, EventArgs e) { var abrvStr = inputBx.Text; foreach (var kvp in d) { abrvStr = abrvStr.Replace(kvp.Key, kvp.Value); } outputBx.Text = abrvStr; } Basically it's part of a dictionary program, so that when you enter a line of text in textbox 1 it appears in textbox 2 with a word replaced from textbox 1 in the dicitonary. So if black,white is in the dictionary and I enter The wall is

How can I create subclass of class Inline ? (the one used in FlowDocument)

不羁岁月 提交于 2019-12-04 05:36:52
In WPF I would like to create custom Inline implementation. From documentation of Inline : "An abstract class that provides a base for all inline flow content elements." Classes like Figure , Run or Span inherit from Inline . My custom class inheriting from Inline would be something like '2 lined Run'. I have special needs for flow of document and this seems to be the only way. However I don't know where to start: Inline does not define any members! It is abstract class so it is meant to be inherited but there is no documentation on how to inherit from it. Not in MSDN and nowhere else where I

Unexpected result of RTF line ending conversion

 ̄綄美尐妖づ 提交于 2019-12-04 04:48:09
问题 If txtLog is a RichTextBox control: Dim text = "hi" & vbCrLf Debug.WriteLine("t:" & text.Length) ' --> 4, as expected txtLog.Text = text Debug.WriteLine("tL:" & txtLog.TextLength) ' --> 3. muh?! :( Having looked at the RTF spec, the end of a paragraph is notated as \par , which is neither CR nor LF . This makes sense since RTF is markup language; like in HTML, line endings have little meaning on their own. So presumably, on writing into the RichTextBox , my line ending is being encoded into

User selecting text in RichTextBox on Windows Phone 8

狂风中的少年 提交于 2019-12-04 04:30:08
问题 I am trying to use a RichTextBox in my Windows Phone 8 application. The user needs to be able to select text and copy it to the clipboard. The user DOES NOT need to edit the text, only select it. However, I cannot seem to select text in either the Windows Phone Emulator, or on my Windows Phone 8 device (Nokia 920). The documentation for the RichTextBox.Selection property contains example code for how to change the format of the selected text (bold, italic, etc.). I would assume that the user