
RtxtTextBox.SelectionStart = rtxtTextBox.SelectionStart + rtxtTextBox.SelectionLength If(MessageBox.Show("Do you want to paste over current Selection","Paste Example",MessageBoxButtons.YesNo)=DialogResult.No) If(Clipboard.GetDataObject().GetDataPresent("Text")=true) Private void btnPaste_Click(object sender, EventArgs e) Private void btnCopy_Click(object sender, EventArgs e) RtxtTextBox.SelectionFont = new Font("Verdana", 12, FontStyle.Bold) RtxtTextBox.Find("Text Box", RichTextBoxFinds.MatchCase) Private void btnFind_Click(object sender, EventArgs e) RtxtTextBox.LoadFile("My Rich Text File.rtf") Private void btnLoad_Click(object sender, EventArgs e) RtxtTextBox.SaveFile("My Rich Text File.rtf", RichTextBoxStreamType.RichText) Private void btnSave_Click(object sender, EventArgs e) Clear the undo buffer to prevent last action from being redone. Determine if last operation can be undone in text box. Private void Menu_Undo(System.Object sender, System.EventArgs e) If (richTextBox1.RedoActionName != "Delete") Determines if the redo operation deletes text. Determines if a Redo operation can be performed. The CanRedo method can help us decide if the control can be reapplied to the last operation that the user has undone.

Protect the selected text in the control from being altered.īy using the Undo and Redo techniques, We can undo and rework most of the operations in a RichTextBox control. MessageBox.Show("The text \" My RichTextBox\" was not found!") Alert the user that the word was not foun and return. If(richTextBox1.Find("My RichTextBox",RichTextBoxFinds.WholeWord)= -1) Search for the word RichTextBox in the control.

If(richTextBox1.SelectedText != " My RichTextBox") Determine if the selected text in the control contains the word " My RichTextBox". (e.LinkText) īy setting the SelectionProtected property to true, we can stop the user from manipulate some or all of the text in the control.

Private void Link_Clicked (object sender, e)
#RICH TEXT BOX CODE#
This value is valid only for use with the RichTextBox control, SaveFile(String) method.įor links in web-type style, we can also use a RichTextBox control by setting DetectUrls to true and write code to handle the LinkClicked event. In Unicode, the text is encoded.Ī Rich Text Format (RTF) stream with OLE objects spaces. This is valid only for use with the RichTextBox, SaveFile(String) method.Ī text stream that includes object spaces instead of objects linked and embedded (OLE). FieldsĪ plain text stream containing space in OLE (objects Linking and Embedding) objects.Ī plain text stream, representing OLE objects textually. Specifies the input and output stream types for loading and saving data in the RichTextBox control. The possible file formats are listed in RichTextBoxStreamType The LoadFile and SaveFile processes can show and write several file format including plain text, Unicode plain text and Rich Text Format (RTF) to manipulate documents.

#RICH TEXT BOX HOW TO#
How to Set Indents, Hanging Indents, and Bulleted Paragraphs with RichTextBox Control? RichTextBox1.SelectionFont = new Font("Tahoma", 12, FontStyle.Bold) How to Set Font Attributes for RichTextBox Control? The controller RichTextBox has many text formatting characteristics. The text displayed is set by the Text property, just like the TextBox command. Like Textbox, scroll bars can be displayed with RichTextBox control unlike TextBox, its default configuration is to show scroll bars both horizontal and vertical as required and has extra scroll bar configurations. The RichTextBox control is typically used for manipulating texts and displaying functionality similar to text processing applications such as Microsoft Word. The control RichTextBox does everything the control of the TextBox does but can show fonts, colors and links load images and text from a file and find the characters that we specify.
#RICH TEXT BOX WINDOWS#
The RichTextBox control for Windows Forms is used for displaying, typing and formatting of text.
