Search Results

Search found 216 results on 9 pages for 'richtextbox'.

Page 1/9 | 1 2 3 4 5 6 7 8 9  | Next Page >

  • Sharing WPF RichTextBox content with Silverlight RichTextBox

    - by Stewart Armbrecht
    Has anyone figured out the best way to persist a WPF and Silverlight RichTextBox content so that it can be shared between the two? I haven't had the time to test through this so I wanted to see if anyone else has. I currently have a WPF applicaiton that saves the content of a RichTextBox as a blob in the database using the following code: byte[] result = null; TextRange range = new TextRange(flowDocument.ContentStart, flowDocument.ContentEnd); if (range.IsEmpty == false) { using (MemoryStream strm = new MemoryStream()) { range.Save(strm, DataFormats.XamlPackage, true); result = strm.ToArray(); strm.Close(); } } return result; I am building a silverlight version of the application and want to know how I can load (and save) this content using the Silverlight RichTextBox so that it can still be using in the WPF application.

    Read the article

  • Bindable richTextBox still hanging in memory {WPF, Caliburn.Micro}

    - by Paul
    Hi, I use in WFP Caliburn.Micro Framework. I need bindable richTextbox for Document property. I found many ways how do it bindable richTextBox. But I have one problem. From parent window I open child window. Child window consist bindable richTextBox user control. After I close child window and use memory profiler view class with bindabelrichTextBox control and view model class is still hanging in memory. - this cause memory leaks. If I use richTextBox from .NET Framework or richTextBox from Extended WPF Toolkit it doesn’t cause this memory leak problem. I can’t identified problem in bindable richTextBox class. Here is ist class for bindable richTextBox: Base class can be from .NET or Extended toolkit. /// <summary> /// Represents a bindable rich editing control which operates on System.Windows.Documents.FlowDocument /// objects. /// </summary> public class BindableRichTextBox : RichTextBox { /// <summary> /// Identifies the <see cref="Document"/> dependency property. /// </summary> public static readonly DependencyProperty DocumentProperty = DependencyProperty.Register("Document", typeof(FlowDocument), typeof(BindableRichTextBox)); /// <summary> /// Initializes a new instance of the <see cref="BindableRichTextBox"/> class. /// </summary> public BindableRichTextBox() : base() { } /// <summary> /// Initializes a new instance of the <see cref="BindableRichTextBox"/> class. /// </summary> /// <param title="document">A <see cref="T:System.Windows.Documents.FlowDocument"></see> to be added as the initial contents of the new <see cref="T:System.Windows.Controls.BindableRichTextBox"></see>.</param> public BindableRichTextBox(FlowDocument document) : base(document) { } /// <summary> /// Raises the <see cref="E:System.Windows.FrameworkElement.Initialized"></see> event. This method is invoked whenever <see cref="P:System.Windows.FrameworkElement.IsInitialized"></see> is set to true internally. /// </summary> /// <param title="e">The <see cref="T:System.Windows.RoutedEventArgs"></see> that contains the event data.</param> protected override void OnInitialized(EventArgs e) { // Hook up to get notified when DocumentProperty changes. DependencyPropertyDescriptor descriptor = DependencyPropertyDescriptor.FromProperty(DocumentProperty, typeof(BindableRichTextBox)); descriptor.AddValueChanged(this, delegate { // If the underlying value of the dependency property changes, // update the underlying document, also. base.Document = (FlowDocument)GetValue(DocumentProperty); }); // By default, we support updates to the source when focus is lost (or, if the LostFocus // trigger is specified explicity. We don't support the PropertyChanged trigger right now. this.LostFocus += new RoutedEventHandler(BindableRichTextBox_LostFocus); base.OnInitialized(e); } /// <summary> /// Handles the LostFocus event of the BindableRichTextBox control. /// </summary> /// <param title="sender">The source of the event.</param> /// <param title="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> void BindableRichTextBox_LostFocus(object sender, RoutedEventArgs e) { // If we have a binding that is set for LostFocus or Default (which we are specifying as default) // then update the source. Binding binding = BindingOperations.GetBinding(this, DocumentProperty); if (binding.UpdateSourceTrigger == UpdateSourceTrigger.Default || binding.UpdateSourceTrigger == UpdateSourceTrigger.LostFocus) { BindingOperations.GetBindingExpression(this, DocumentProperty).UpdateSource(); } } /// <summary> /// Gets or sets the <see cref="T:System.Windows.Documents.FlowDocument"></see> that represents the contents of the <see cref="T:System.Windows.Controls.BindableRichTextBox"></see>. /// </summary> /// <value></value> /// <returns>A <see cref="T:System.Windows.Documents.FlowDocument"></see> object that represents the contents of the <see cref="T:System.Windows.Controls.BindableRichTextBox"></see>.By default, this property is set to an empty <see cref="T:System.Windows.Documents.FlowDocument"></see>. Specifically, the empty <see cref="T:System.Windows.Documents.FlowDocument"></see> contains a single <see cref="T:System.Windows.Documents.Paragraph"></see>, which contains a single <see cref="T:System.Windows.Documents.Run"></see> which contains no text.</returns> /// <exception cref="T:System.ArgumentException">Raised if an attempt is made to set this property to a <see cref="T:System.Windows.Documents.FlowDocument"></see> that represents the contents of another <see cref="T:System.Windows.Controls.RichTextBox"></see>.</exception> /// <exception cref="T:System.ArgumentNullException">Raised if an attempt is made to set this property to null.</exception> /// <exception cref="T:System.InvalidOperationException">Raised if this property is set while a change block has been activated.</exception> public new FlowDocument Document { get { return (FlowDocument)GetValue(DocumentProperty); } set { SetValue(DocumentProperty, value); } } } Thank fro help and advice. Qucik example: Child window with .NET richTextBox <Window x:Class="WpfApplication2.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Grid> <RichTextBox Background="Green" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" FontSize="13" Margin="4,4,4,4" Grid.Row="0"/> </Grid> </Window> This window I open from parent window: var w = new Window1(); w.Show(); Then close this window, check with memory profiler and it memory doesn’t exist any object of window1 - richTextBox. It’s Ok. But then I try bindable richTextBox: Child window 2: <Window x:Class="WpfApplication2.Window2" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Controls="clr-namespace:WpfApplication2.Controls" Title="Window2" Height="300" Width="300"> <Grid> <Controls:BindableRichTextBox Background="Red" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" FontSize="13" Margin="4,4,4,4" Grid.Row="0" /> </Grid> </Window> Open child window 2, close this child window and in memory are still alive object of this child window also bindable richTextBox object.

    Read the article

  • Display Special Characters (Korean Letters) in RichTextBox

    - by Peter Lee
    Hi, My question might be a little bit confusing, but I think it's still worth of paying some attention. Basically I'm designing a program to display all printable Unicode characters in a RichTextBox. I'm using VC# 2010 Express Edition. However, the RichTextBox has a critical problem: some special characters cannot be displayed correctly. For example, some Korean Characters (??????????????????????????????), can be displayed correctly in Microsoft Word. After I copy to the RichTextBox, the characters cannot be displayed correctly. However, when I copy back to Microsoft Word, it can be displayed correctly. Therefore, it's a display problem (the characters themselves are correct). I guess it might be a font problem. Some related property info: RichTextBox.Font.GdiChaSet RichTextBox.Font How can I solve it? So that all printable Unicode characters can be displayed correctly (using different fonts for different CharSets are acceptable). Actually, I need further assistance about removing all formatting when pasting rtbxFileContent.Paste(DataFormats.GetFormat(DataFormats.Text)); // DataFormats.UnicodeText I still need to have all printable characters to be displayed correctly, but without any formatting (except font). Thanks. Hope I made myself understood.

    Read the article

  • RichTextBox CaretPosition physical location

    - by Jan Kratochvil
    Hi, I'm using a RichTextBox class to make some automatic text formatting. And mz question is, how do I get the RichTextBox to put some string immediately after the caret. When I use RichTextBox.CaretPosition.InsertTextInRun("some string") the text is inserted after the current logical block, but I need to be insterted immediately after the caret, in the middle of a Run block. I hope it's clear, thx very much.

    Read the article

  • .NET RichTextBox: unable to change Rtf property.

    - by Dave
    Hey guys, Perhaps I'm missing something real simple here, but I've been struggling to change the RTF property of my RichTextBox in order to apply some color coding to my text. Probably the most straight-forward example of the problem I'm having is setting the Rtf property to include a color table in its header. The default RTF string returned by the Rtf property: {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}\viewkind4\uc1\pard\f0\fs17\par} And the new RTF string I'd like to set with my color table: {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}{\colortbl;\red128\green0\blue0;\red0\green128\blue0;\red0\green0\blue255;}}\viewkind4\uc1\pard\f0\fs17\par} And I set this using: RichTextBox richTextBox = new RichTextBox(); richTextBox.Rtf = rtfStr; // My new RTF string, as seen above. However, via debugger, it can be observed the that Rtf property stubbornly refuses to change; no exceptions are thrown, it just refuses to change. Same issue happens when I string.Replace() words to include RTF color tags around them. I've also tried turning off any ReadOnly properties on the text box. Any suggestions would be most helpful, thanks! Dave

    Read the article

  • Rectangular BackColor of selection in RichTextBox

    - by AgentConundrum
    Background: I'm going to start studying/coding at the local university's library. Since I'm not a student, I won't be able to utilize their wireless internet access. Since StackOverflow is such a great resource, I want to be able to take it with me, so I'm building a small desktop application to load/search/display the most recent data dumps. Problem: I want to display code blocks in the same sort of rectangular block as this site does, so I played with the RichTextBox control to try to create this effect. Unfortunately, the RichTextBox.SelectedBackColor property only colors the actual text, when what I want is a rectangle reaching to the outer limits of the selection. Example: This is what I am able to produce with the RichTextBox: This is what I would like to create: Questions: Is there any way to produce this effect using the RichTextBox? If not, are there any other controls I could use to create this effect?

    Read the article

  • WPF: RichTextBox typing TWICE slower than in a VB 5.0 RichTextBox ...

    - by msfanboy
    Hello, first this is no rant although its worth alone to put it on a blog... When I type very fast - having roughly 260 chars/minute - WPF`s RichTextBox starts swallowing chars and I have to stop writing that fast a = a.IsAnnoying = true; The same in a VB 5.0 RichTextBox fast as hell. Why is WPF again so great for? Customer satisfactory ? Seriously, is there something I can tweak to make RichTextBox better responding?

    Read the article

  • Broken tables in RichTextBox control (word wrap)

    - by Ben Robbins
    We are having problems with the Windows.Forms.RichTextBox control in Visual Studio 2008. We are trying to display text supplied as an RTF file by a 3rd party in a windows forms application (.NET 3.5). In this RTF text file there are tables, which contain text that spans multiple lines. The RTF file displays correctly when opened with either WordPad or Word 2003. However, when we load the RTF file into the RichTextBox control, or copy & paste the whole text (including the table) into the control, the table does not display correctly - the cells are only single line, without wrapping. Here are links to images showing the exact problem: Correctly displayed in WordPad Incorrectly displayed in RichTextBox control I have googled for solutions and 3rd party .net RTF controls without success. I have found this exact problem asked on another forum without an answer (in fact that's where the link to the images come from) so I'm hoping stack overflow does better ;-) My preferred solution would be to use code or a 3rd party control that can correctly render the RTF. However, I suspect the problem is that the RichTextBox control only supports a subset of the full RTF spec, so another option would be to modify the RTF directly to remove the unsupported control codes or otherwise fix the RTF file itself (in which case any information as to what control codes need to be removed or modified would be a huge help).

    Read the article

  • Setting WPF RichTextBox width and height according to the size of a monospace font

    - by oxeb
    I am trying to fit a WPF RichTextBox to exactly accommodate a grid of characters in a particular monospace font. I am currently using FormattedText to determine the width and height of my RichTextBox, but the measurements it is providing me with are too small--specifically two characters in width too small. Is there a better way to perform this task? This does not seem to be an appropriate way to determine the size of my control. RichTextBox rtb; rtb = new RichTextBox(); FontFamily fontFamily = new FontFamily("Consolas"); double fontSize = 16; char standardizationCharacter = 'X'; String standardizationLine = ""; for(long loop = 0; loop < columns; loop ++) { standardizationLine += standardizationCharacter; } standardizationLine += Environment.NewLine; String standardizationString = ""; for(long loop = 0; loop < rows; loop ++) { standardizationString += standardizationLine; } Typeface typeface = new Typeface(fontFamily, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal); FormattedText formattedText = new FormattedText(standardizationString, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, fontSize, Brushes.Black); rtb.Width = formattedText.Width; rtb.Height = formattedText.Height;

    Read the article

  • How to append \line into RTF using RichTextBox control

    - by Steve Sheldon
    When using the Microsoft RichTextBox control it is possible to add new lines like this... richtextbox.AppendText(System.Environment.NewLine); // appends \r\n However, if you now view the generated rtf the \r\n characters are converted to \par not \line How do I insert a \line control code into the generated RTF? What does't work: Token Replacement Hacks like inserting a token at the end of the string and then replacing it after the fact, so something like this: string text = "my text"; text = text.Replace("||" "|"); // replace any '|' chars with a double '||' so they aren't confused in the output. text = text.Replace("\r\n", "_|0|_"); // replace \r\n with a placeholder of |0| richtextbox.AppendText(text); string rtf = richtextbox.Rtf; rtf.Replace("_|0|_", "\\line"); // replace placeholder with \line rtf.Replace("||", "|"); // set back any || chars to | This almost worked, it breaks down if you have to support right to left text as the right to left control sequence always ends up in the middle of the placeholder. Sending Key Messages public void AppendNewLine() { Keys[] keys = new Keys[] {Keys.Shift, Keys.Return}; SendKeys(keys); } private void SendKeys(Keys[] keys) { foreach(Keys key in keys) { SendKeyDown(key); } } private void SendKeyDown(Keys key) { user32.SendMessage(this.Handle, Messages.WM_KEYDOWN, (int)key, 0); } private void SendKeyUp(Keys key) { user32.SendMessage(this.Handle, Messages.WM_KEYUP, (int)key, 0); } This also ends up being converted to a \par Is there a way to post a messaged directly to the msftedit control to insert a control character? I am totally stumped, any ideas guys? Thanks for your help!

    Read the article

  • HTML to XAML Conversion, Display HTML in RichTextBox

    - by Erika
    Hi, unfortunately im REALLY stuck on this and was wondering in anyone knows how to work around this. I have some html text which i want displayed in a WPF RichTextBox. At the moment, i'm using some helper APIs found http://blogs.msdn.com/wpfsdk/archive/2006/05/25/606317.aspx to convert HTML to XAML. So at the moment i have a xaml data string, but i cant see to find a way to display this correctly within the richtextbox :s i have been trying the following: string xamlData = HTMLConverter.HtmlToXamlConverter.ConvertHtmlToXaml(sBody,true); FlowDocument result = XamlReader.Load(new System.Xml.XmlTextReader(new StringReader(xamlData))) as FlowDocument; but this is crashing on the XamlReader.. Any other way will do, i just need to display an HTML string in this RichTextBox or something else! Please Help!

    Read the article

  • RichTextBox No Border

    - by rishi
    Hello, Based on what Word, Wordpad, and Open Office Writer are showing there is no cell border which is correct. But in the RichTextBox control the borders are displayed. I need to hide the borders of the table/rows/cells in the richtextbox. Any help would be greatly appreciated. Please see the sample below for RTF. {\rtf1\ansi\deff0 RichTextBox without borders ???? \line\par \trowd\trgaph144 \clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs \cellx5000 Single border\intbl\cell \row\pard\par }

    Read the article

  • WPF RichTextBox - Formatting of typed text

    - by Alan Spark
    I am applying formatting to selected tokens in a WPF RichTextBox. To do this I get a TextRange that encompasses the token that I would like to highlight. I will then change the color of the text like this: textRange.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Blue); This is happening on the TextChanged event of my RichTextBox. The formatting is applied as expected, but continuing to type text will result in the new text inheriting the formatting that has already been applied to the adjacent word. I would like the formatting of any new text to use the default formatting options defined in the RichTextBox properties. Is this possible? Alternatively I could highlight all tokens that I don't want be blue with the default formatting options but this feels awkward to me.

    Read the article

  • WPF RichTextBox with no width set

    - by Mick
    I have the following XAML code: <Window x:Class="RichText_Wrapping.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1"> <Grid> <RichTextBox Height="100" Margin="2" Name="richTextBox1"> <FlowDocument> <Paragraph> This is a RichTextBox - if you don't specify a width, the text appears in a single column </Paragraph> </FlowDocument> </RichTextBox> </Grid> ... If you create this window in XAML, you can see that when you don't specify a width for the window, it wraps the text in a single column, one letter at a time. Is there something I'm missing? If it's a known deficiency in the control, is there any workaround? Thanks, Michael

    Read the article

  • Force Richtextbox scrollbars to refresh

    - by Jiri
    This question is about WinForms RichTextbox. I have a RichTextbox with ScrollBars property set to Vertical. I change it's RTF contents from the code and sometimes the vertical scrollbar appears disabled - when it should be enabled. This should never happen - the scrollbar should be either enabled, or not shown at all. (I had a similar issue in my VB6 app, when the scrollbar sometimes didn't appear at all when it should). Is there any way how to force the RichTextbox scrollbars to refresh, via PInvoke or any other way to fix this issue? Thanks.

    Read the article

  • c# RichTextBox Tab size

    - by Bala R
    Hello, I'm using System.Windows.Forms.RichTextBox and by default the tab size is 8 spaces. The RichTextBox itself is not that big and 8 spaces leads to a lot of scrolling. Is there any way to make it 4 spaces. If it matters, the control is initially blank and the user starts entering stuff and the tabs have to shorter (4 spaces) as the user enters text with tabs. I tried http://stackoverflow.com/questions/154204/modifying-default-tab-size-in-richtextbox and a few variations of it but no luck.

    Read the article

  • Disable Drag&Drop of files in Richtextbox in .NET

    - by Jiri
    Hello, I use a .NET richtextbox and I want to have the EnableAutoDragDrop property set to True. This allows user to drag&drop text, rtf and images around etc. However, I need to process files dropped into the richtextbox myself - I do not want them to be embedded as OLE objects when they are dropped. How can I overcome this? Is there any way to delete embedded files from richtextbox? (I've found API DragAcceptFiles which doesn't work for some reason.) Thanks!

    Read the article

  • Handle Silverlight 4 RichTextBox Paste event

    - by iulianchira
    How can I handle the Paste event for a RichTextBox control in Silverlight 4? (I want to be able to copy-paste images - the Clipboard in SL4 supports only text, so I'm sending the ImageSource Uri, and on the Paste event I want to load the image in the RichTextBox instead of the Uri string).

    Read the article

  • Richtextbox wpf binding

    - by Alex Maker
    To do DataBinding of the Document in a WPF RichtextBox, I saw 2 Solutions so far, which are to derive from the RichtextBox and add a DependencyProperty, and also the solution with a "proxy". Neither the first or the second are satisfactory. Does somebody know another solution, or instead, a commercial RTF control which is capable of DataBinding? The normal Textbox ist not an alternative, since we need text formating. Any idea?

    Read the article

  • Silverlight RichTextBox Disable Mouse Selection

    - by Fastidious
    I am writing a custom control based on RichTextBox that needs the ability to process MouseLeftButtonDown events but must not allow user-initiated selection (I'm doing everything programmatically). I tried setting a flag in MouseLeftButtonDown to track dragging and then continuously setting the RichTextBox.Selection to nothing in the MouseMove event but the move event isn't fired until after I release the mouse button. Any ideas on how to solve this? Thanks.

    Read the article

  • WPF RichTextBox support for document links?

    - by Rox Wen
    I'm attempting to render RTF documents using the WPF RichTextBox control. So far, the appearance of the rendered RTF documents is quite true to the originals which were authored using MS Word. The one issue I've found is that the "document anchors" which are hyperlinks to different locations within the document, do not function as hoped. While they look like links, clicking on them does nothing. Can the WPF RichTextBox support this type of link?

    Read the article

1 2 3 4 5 6 7 8 9  | Next Page >