richtextbox

C# WPF convert BitmapImage pasted in richtextbox to binary

南笙酒味 提交于 2019-12-03 13:51:31
I've got a richtextbox, that I plan on saving to a database, which can be loaded back into the same richtextbox. I've got it working so that I can save the flowdocument as DataFormats.XamlPackage, which saves the images, but the issue is that the text isn't searchable. With DataFormats.Xaml, I've got the text of course, but no images. The images will be pasted in by the end user, not images included with the application. I tried using XamlWriter to get the text into XML, and then grab the images from the document separately and insert them as binary into the XML, but I can't seem to find a way

Space After New Lines in RichTextBox

点点圈 提交于 2019-12-03 13:47:10
A RichTextBox puts extra space between lines when a user presses enter or inserts text, and that's what I'm trying to get away from. I searched around and the only decent solution I found is this one: Setter SetParagraphMargin = new Setter(); SetParagraphMargin.Property = Paragraph.MarginProperty; SetParagraphMargin.Value = new Thickness(0); Style style = new Style(); style.TargetType = typeof(Paragraph); style.Setters.Add(SetParagraphMargin); rtb.Resources.Add("Style", style); But this still doesn't work. Does anyone have any tips for me? Botz3000 I had the same problem, and i solved it by

WPF RichTextBox appending coloured text

一世执手 提交于 2019-12-03 08:36:02
问题 I'm using the RichTextBox.AppendText function to add a string to my RichTextBox . I'd like to set this with a particular colour. How can I do this? 回答1: Just try this: TextRange tr = new TextRange(rtb.Document.ContentEnd,­ rtb.Document.ContentEnd); tr.Text = "textToColorize"; tr.ApplyPropertyValue(TextElement.­ForegroundProperty, Brushes.Red); 回答2: If you want, you can also make it an extension method. public static void AppendText(this RichTextBox box, string text, string color) {

WPF: Allow user to resize images in RichTextBox

强颜欢笑 提交于 2019-12-03 08:29:32
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 programming it? Or am I looking at the wrong control altogether? Turns out you need to wrap your image in a

How to show number of a line in a RichTextBox C#

这一生的挚爱 提交于 2019-12-03 07:32:38
问题 I am making a simple text and script editor with code highlighting. For that I use a RichTextBox. But I don't know how to make it show the lines' numbers on the left side, like in VS or Notepad++. Is there any solution? 回答1: I tried re-using the code from the codeproject articles referenced elsewhere, but every option I looked at, seemed a bit too kludgy. So I built another RichTextBoxEx that displays line numbers. The line numbering can be turned on or off. It's fast. It scrolls cleanly. You

Highlight text in RichTextBox

落爺英雄遲暮 提交于 2019-12-03 06:02:37
问题 I'm trying to use a RichTextBox and my first feeling : "What's it's complicated to use !"... Amazing ... So I'm trying to highlight a text contained in my RichTextBox. I currently have the following code: TextRange range = new TextRange(MyTextInput.Document.ContentStart, MyTextInput.Document.ContentEnd); range.Text = @"TOP a multiline text or file END"; Regex reg = new Regex("(top|file|end)", RegexOptions.Compiled | RegexOptions.IgnoreCase); foreach (Match match in reg.Matches(range.Text)) {

Decrease the line spacing in TinyMCE textarea

99封情书 提交于 2019-12-03 05:52:50
I am using TinyMCE to provide a rich text editing text editor. But the line spacing between the lines is too much. I have added a screenshot that shows the line spacing I get on pressing an enter. What can be done about it There is a css class that is applied to the TinyMCE html content. It looks like you have <p> tags causing the spacing. Honestly, it looks pretty good to me. But you can override in the css class: .tinymce-content p { padding: 0; margin: 2px 0; } See the tinymce docs for more info. You can add custom css to your CSS-editor like this: tinyMCE.init({ ... editor_css : "/content

jQuery plugin that suggests/autocompletes within a textarea [closed]

家住魔仙堡 提交于 2019-12-03 05:15:59
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . Is there a jQuery plugin that suggests/autocompletes within a textarea? What I want is to have suggested words or autocompleted text proffered to the user in a textarea like the example image below: 回答1: Well there is the autocomplete plugin that does just that, and if you want to pull data from a database I

Best way to implement a Parsing/Editable Richtextbox in WPF

牧云@^-^@ 提交于 2019-12-03 04:51:26
I'm trying to implement (as a prototype initially), a richtextbox control which can be parsed in real time to apply certain formatting options to it. This is being done in WPF so I thought the best way to go about it would be to extend the existing rich text box control. I've run into the issue where it isn't documented well and the examples are quite slow (the ones I found have parse the whole document on every keystroke). The way I've currently decided to go about it is to create a custom Inline element which can hold the formatting tags, and the contents. Hence I only have to parse the

c# RTB - paste plain text without colours/fonts?

試著忘記壹切 提交于 2019-12-03 04:28:28
I am using Rich Text object in my C# application. The only issue I am having is that when user pastes formated text from another app, it remains formated which I cannot have. Is there any way how to paste only string and ignore formatting? Thanks! Assuming WinForms : try this : define a RichTextBox with a KeyDown event handler like this : Append-only example : private void richTextBox1_KeyDown(object sender, KeyEventArgs e) { if (e.Control && e.KeyCode == Keys.V) { richTextBox1.Text += (string)Clipboard.GetData("Text"); e.Handled = true; } } [Edit] Add Clipboard RTF to RichTextBox at current