Search Results

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

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

  • Windows.Forms RichTextBox Control - Avoid inserting large data.

    - by SchlaWiener
    I have a Windows Form with a RichTextBox on it. The content of the RichTextBox is written to a database field that ist limited to 64k data. For my purpose that is way more than enough text to store. I have set the MaxLength property to avoid insertng more data than allowed. rtcControl.MaxLength = 65536 Howevery, that only restricts the amount of characters that so is allowed to put in the text. But with the formatting overhead from the Rtf I can type more text than I should be allowed to. It even get's worse if I insert a large image, which dosn't increase the TextLength at all but the Rtf Length grows quite a lot. At the moment I check the Length of the richttextboxes' Rtf property in the FormClosing event and display a message to the user if it's to large. However that is just a workaround because I want to disallow putting more data than allowed into the control (like in a textbox if you exceed the MaxLength property nothing is inserted into the control and you hear the default beep(). Any ideas how to achive this? I already tried: using a custom control which extends the richtextbox and shadows th Rtf property to intercept the insertation. But it seems it isn't executed if I add text. Even the TextChanged Event does not fire if I type smth. in the control.

    Read the article

  • RichTextBox text is not shown C#

    - by user271077
    using richtextbox control programatically i'm appending text to the richtextbox . richTextBox1.AppendText("hello"); somehow the text appears in the richTextBox1.Text but is not shown in the form. any idea of what might be the problem? (I checked the forecolor seems ok). Thanks in advance Edit: found the root cause (had by mistake the initializeComponent() twice. ) private void InitializeComponent() { this.richTextBox1 = new System.Windows.Forms.RichTextBox(); this.SuspendLayout(); // // richTextBox1 // this.richTextBox1.Location = new System.Drawing.Point(114, 104); this.richTextBox1.Name = "richTextBox1"; this.richTextBox1.Size = new System.Drawing.Size(100, 96); this.richTextBox1.TabIndex = 0; this.richTextBox1.Text = ""; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(284, 262); this.Controls.Add(this.richTextBox1); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false); } public Form1() { InitializeComponent(); InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { richTextBox1.AppendText("hello world"); }` but still curious about why did this cause this weird behavior?

    Read the article

  • Convert XAML to FlowDocument to display in RichTextBox in WPF

    - by Erika
    I have some HTML, which i am converting to XAML using the library provided by Microsoft string t = HtmlToXamlConverter.ConvertHtmlToXaml(mail.HtmlDataString,true); now, from http://stackoverflow.com/questions/1449121/how-to-insert-xaml-into-richtextbox i am using the following: private static FlowDocument SetRTF(string xamlString) { StringReader stringReader = new StringReader(xamlString); System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create(stringReader); Section sec = XamlReader.Load(xmlReader) as Section; FlowDocument doc = new FlowDocument(); while (sec.Blocks.Count > 0) doc.Blocks.Add(sec.Blocks.FirstBlock); return doc; } This however keeps crashing unfortunately =/ Does anyone have any clue on how to display XAML text in a RichTextBox please?

    Read the article

  • Silverlight 4 RichTextBox - can't restore Xaml with text containing curly braces

    - by fuzzyman
    We have a Silverlight application using the RichTextBox as a rich text editor for the user to create emails. We actually have our own serializer but essentially we are saving and restoring the Xaml. As far as I can tell it is impossible to restore any text containing curly braces. You can demonstrate this fairly easily by creating a RichTextBox and typing something similar to "{weird}" into it. Then take the .Xaml property of the textbox and set it on the .Xaml property of another textbox - kablooie. As we have our own serializer I have tried escaping the Text member of the Run elements with "". This makes no difference. I've tried replacing the braces with &#123; but that doesn't work either.

    Read the article

  • Change color of text within a WinForms RichTextBox

    - by Addie
    I have a RichTextBox that I write a string to every time I click a Form button. The string ends with a newline so each time I add a string, it appends to the bottom of the RichTextBox. Each string begins with the string "Long" or "Short" and ends with Environment.NewLine. I'd like to color each line red if it beings with "Long" and blue if it begins with "Short". How can I do this? If you need further clarification of the question comment below.

    Read the article

  • Adding image to RichTextBox programatically does not show in Xaml property

    - by rotary_engine
    Trying to add an image to a RichTextBox progamatically from a Stream. The image displays in the text box, however when reading the Xaml property there is no markup for the image. private void richTextBox3_Drop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { FileInfo[] files = (FileInfo[])e.Data.GetData(DataFormats.FileDrop); using (Stream s = files[0].OpenRead()) { InlineUIContainer container = new InlineUIContainer(); BitmapImage bmp = new BitmapImage(); bmp.SetSource(s); Image img = new Image(); img.SetValue(Image.SourceProperty, bmp); container.Child = img; richTextBox3.Selection.Insert(container); } } } private void Button_Click_1(object sender, RoutedEventArgs e) { // this doesn't have the markup from the inserted image System.Windows.MessageBox.Show(richTextBox3.Xaml); } What is the correct way to insert an image into the RichTextBox at runtime so that it can be persisted to a data store? In the Xaml property.

    Read the article

  • Change color of text within a RichTextBox in C#

    - by Addie
    I have a RichTextBox that I write a string to every time I click a Form button. The string ends with a newline so each time I add a string, it appends to the bottom of the RichTextBox. Each string begins with the string "Long" or "Short" and ends with Environment.NewLine. I'd like to color each line red if it beings with "Long" and blue if it begins with "Short". How can I do this? If you need further clarification of the question comment below.

    Read the article

  • Undo/Redo Support for Table Changes in WPF RichTextBox

    - by Jeff
    As part of an editor project, I need to add functionality to the WPF RichTextBox control to allow the user to perform operations on a table. One of those operations is to apply a new width value to one or more columns of the table. I have a function that is applying a new Width value to the TableColumn objects in question, and the table is resizing itself nicely. However, I've noticed that the column-width change operation does not seem to be added to the undo stack. In other words, if a user types something, then changes a column width, then selects undo, the RichTextBox control undoes the user's typing. Undo and redo don't seem to be picking up the property change on the TableColumn object. Is there some way to make this operation occur in a way that it actually is undoable/redoable?

    Read the article

  • Problem with finding the next word in RichTextBox

    - by paradisonoir
    As I enter a character in my RichTextBox, I want to get the next character from the its TextRange. So here is how I do it: TextPointer ptr1= RichTextBox.CaretPosition; char nextChar = GetNextChar(); while (char.IsWhiteSpace(nextChar)) { ptr1= ptr1.GetNextInsertionPosition(LogicalDirection.Forward); nextChar = GetCharacterAt(Ptr1); } then I get the ptr1 of the next character and from the TextPointer, I get the TextRange, and do my changes. So here is the problem? when the next word is spelled correctly, I have no problem, but if it's not spelled properly then ptr1 would not point to the first character of the next word (the second character), and if I use GetNextContextPosition(LogicalDirection.Forward) it would give me the first letter of the next word if it's misspelled. So depending on the spelling only one of them works? I was just wondering if you have any idea about this problem? Is there anything wrong I am doing here?

    Read the article

  • Problem loading RTF file into windows richTextBox

    - by Ted
    I am trying to load files into a windows (vs 2010) richTextBox but only the first line of the file is loading. I'm using: // Create an OpenFileDialog to request a file to open. OpenFileDialog openFile1 = new OpenFileDialog(); // Initialize the OpenFileDialog to look for RTF files. openFile1.DefaultExt = "*.rtf"; openFile1.Filter = "RTF Files|*.rtf"; // Determine whether the user selected a file from the OpenFileDialog. if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK && openFile1.FileName.Length > 0) { // Load the contents of the file into the RichTextBox. rtbTest.LoadFile(openFile1.FileName); } The test file I'm using is .cs file saved as an rtf file. Any help appreciated please.

    Read the article

  • C# RichTextBox - Partially setting DetectUrls=false

    - by Suds
    Hi, I have this RichTextBox and I have embedded some http links in it. I have set DetectUrls = true, and it displays the links correctly and handles in the event. In the same RichTextBox, I have one more string displayed which looks like this Type http://< Your host name Now, since DetectUrls= true, the portion "http://<" is displayed as a link, while I want this to be text. If I set the DetectUrls=false just before displaying this string, none of the other links are displayed as links. Is there a way to partially set DetectUrls for some strings and not for others? Thanks

    Read the article

  • WPF Richtextbox XamlWriter behaviour

    - by Krishna
    I am trying to save some c# source code into the database. Basically I have a RichTextBox that users can type their code and save that to the database. When I copy and paste from the visual studio environment, I would like to preserve the formating etc. So I have chosen to save the FlowDocuments Xaml to the database and set this back to the RichTextBox.Document. My below two function serialise and deserialise the RTB's contents. private string GetXaml(FlowDocument document) { if (document == null) return String.Empty; else{ StringBuilder sb = new StringBuilder(); XmlWriter xw = XmlWriter.Create(sb); XamlDesignerSerializationManager sm = new XamlDesignerSerializationManager(xw); sm.XamlWriterMode = XamlWriterMode.Expression; XamlWriter.Save(document, sm ); return sb.ToString(); } } private FlowDocument GetFlowDocument(string xamlText) { var flowDocument = new FlowDocument(); if (xamlText != null) flowDocument = (FlowDocument)XamlReader.Parse(xamlText); // Set return value return flowDocument; } However when I try to serialise and deserialise the following code, I am noticing this incorrect(?) behaviour using System; public class TestCSScript : MarshalByRefObject { } Serialised XAML is using System; public class TestCSScript : MarshalByRefObject {}{ } Notice the the new set of "{}" What am I doing wrong here... Thanks in advance for the help!

    Read the article

  • [WPF] How to register to/listen to richtextbox command's?

    - by Liewe
    I'm creating a simple editor within our application using the WPF RichTextBox. Above it I've added the reguslar buttons like Bold, Italic, etc. These buttons use the RichTextBox's commands to set these properties, but next to these buttons, the commands also get send with CTRL+B, CTRL+I, etc. I want these buttons to represent the current state of the RichTextBox at the cursor. I already found out how to get this state and it works when I update this state on the SelectionChanged event. This event ofcourse isn't fired when Bold is toggled so there is no direct feedback. I would like to know if there is a way to listen to the commands being called, without affecting its original behaviour or some other ideas to solve my problems. I tried listening to the command the following way: CommandBinding boldBinding = new CommandBinding(EditingCommands.ToggleBold, CommandExecuted); _richTextBox.CommandBindings.Add(boldBinding); and private void CommandExecuted(object sender, ExecutedRoutedEventArgs e) { UpdateProperties(); e.Handled = false; } This did update the properties, but the RichTextBox didn't seem to receive the command anymore. I also tried to make my own commands on the control containing the RichTextBox, but when CTRL+B is pressed when the RichTextBox has focus, the original RichTextBox commands are called instead of the new one. Many thanks in advance! Liewe

    Read the article

  • [WPF] How to register to/listen to richtextbox commando's?

    - by Liewe
    I'm creating a simple editor within our application using the WPF RichTextBox. Above it I've added the reguslar buttons like Bold, Italic, etc. These buttons use the RichTextBox's commands to set these properties, but next to these buttons, the commands also get send with CTRL+B, CTRL+I, etc. I want these buttons to represent the current state of the RichTextBox at the cursor. I already found out how to get this state and it works when I update this state on the SelectionChanged event. This event ofcourse isn't fired when Bold is toggled so there is no direct feedback. I would like to know if there is a way to listen to the commands being called, without affecting its original behaviour or some other ideas to solve my problems. I tried listening to the command the following way: CommandBinding boldBinding = new CommandBinding(EditingCommands.ToggleBold, CommandExecuted); _richTextBox.CommandBindings.Add(boldBinding); and private void CommandExecuted(object sender, ExecutedRoutedEventArgs e) { UpdateProperties(); e.Handled = false; } This did update the properties, but the RichTextBox didn't seem to receive the command anymore. I also tried to make my own commands on the control containing the RichTextBox, but when CTRL+B is pressed when the RichTextBox has focus, the original RichTextBox commands are called instead of the new one. Many thanks in advance! Liewe

    Read the article

  • Multilingual spellcheck on WPF richtextbox

    - by sub-jp
    I need to turn spellcheck on for a richtextbox, and set the language to one the user has picked from a drop down. For now, I'm just testing it by building the richtextbox in xaml and providing a language to the xaml language attribute. I've read two different resources and one says I need to set the language attribute, and the other says I need to set the xml:lang attribute. Neither seems to work. I've tried setting either one to "es" for Spanish, and I've also tried setting both to "es". I've also tried french by setting them to "fr-FR", without success. The only thing that happens is that english words aren't marked, but the other language words are marked as misspelled. I also read that I need to change the keyboard language. This would be a problem for my application as the language within the application needs to be switched on the fly, so having the end user go to their keyboard settings just so spellcheck will work is a problem. However, I've changed my keyboard settings, and spell check still does not work properly. This time it doesn't mark anything as misspelled, even misspelled english words. What am I missing? Edit: some links to my references above http://msdn.microsoft.com/en-us/library/system.windows.controls.spellcheck(v=VS.100).aspx http://www.dev102.com/2008/03/25/customize-spellcheck-on-wpf-text-controls/ http://books.google.com/books?id=clLc5BBHqRMC&pg=PA121&lpg=PA121&dq=C%23+wpf+enable+spellcheck&source=bl&ots=_r59pZRDjP&sig=yHMBc39EHKK5gaRMzxlBaEsY890&hl=en&ei=oXnIS8zWH4G88gaq48yGBw&sa=X&oi=book_result&ct=result&resnum=6&ved=0CBMQ6AEwBQ#v=onepage&q&f=false

    Read the article

  • Silverlight 4 RichTextbox Paragraph Margin or similar?

    - by Nacho
    Hi All, I'm trying to add bullets to the SL4 RichTextBox. Using the Run / Paragraph objects and adding the correct bullet child seems to be an easy approach. However, when I want to apply a bullet to an existing paragraph, I would like to indent the content of the paragraph. How can apply this kind of styling to the paragraph? The margin doesn't exist for the SL version of Paragraph. Thanks.

    Read the article

  • Silverlight 4 RichTextBox - InlineUiContainers disabled

    - by JohnC
    I've been following the Silverlight text editor sample with interest. It gives me a lot of functionality such as formatting, clipboard support, printing etc. The sample also allows for DataGrids to be inserted by using an InlineUiContainer. My problem is that the inserted DataGrid is disabled while my requirement is that the user can edit the contents of the DataGrid. How can I make InlineUiContainers that are inserted in a RichTextBox enabled?

    Read the article

  • Serializing WPF RichTextBox to XAML vs RTF

    - by chaiguy
    I have a RichTextBox and need to serialize its content to my database purely for storage purposes. It would appear that I have a choice between serializing as XAML or as RTF, and am wondering if there are any advantages to serializing to XAML over RTF, which I would consider as more "standard". In particular, am I losing any capability by serializing to RTF instead of XAML? I understand XAML supports custom classes inside the FlowDocument, but I'm not currently using any custom classes (though the potential for extensibility might be enough reason to use XAML).

    Read the article

  • Serializing WPF RichTextBox to XAML vs RTF

    - by chaiguy
    I have a RichTextBox and need to serialize its content to my database purely for storage purposes. It would appear that I have a choice between serializing as XAML or as RTF, and am wondering if there are any advantages to serializing to XAML over RTF, which I would consider as more "standard". In particular, am I losing any capability by serializing to RTF instead of XAML? I understand XAML supports custom classes inside the FlowDocument, but I'm not currently using any custom classes (though the potential for extensibility might be enough reason to use XAML).

    Read the article

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