Search in RichTextBox for C# Windows Forms
KetticRichTextBox WinForms control allows the users to search contents in the document. This is achieved through using some methods for managing the selection of KetticRichTextBox. When the users combine the Search functionality and selection of document together, they can do a lot of operations to the text of document. By the search functionality, we can highlight text of document, as well as replace words and collocations, etc.
C# Search Text in KetticRichTextBox
The following C# code sample demonstrates how to search a string in the text of document in KetticRichTextBox.
The search functionality allows the users to apply all regular expressions and escape the search string by invoking the C# code below.
In addition, the KetticRichTextBox control allows the users to select text from the search results. This functionality will be performed on the parts of the document that are selected currently. The C# code below is an example shows how to customize the selection.
When the users need to remove the selection, they can call the Clear() method of the DocumentSelection object as the simple C# code snippet as below.
Moreover, KetticRichTextBox control allows the users to extend the search and selection functionality to replace the text of searched results. The following C# code demonstrates how to replace the searched string.
When we add or remove strings to the document, the positions will be changed, so that we may need to create new TextRanges with document positions to tack the changes. The users can enable the second property of the two properties constructor to keep the relative position when the document changes. |
UI Controlsfor Windows Forms .NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI DesignWinForms UI Controls WinForms Buttons UI Control WinForms Calendar UI ControlWinForms Carousel UI ControlWinForms Chart UI ControlWinForms Clock UI ControlCommandBar UI ControlWinForms Dock UI ControlDesktop Alert UI ControlDropDown List UI ControlWinForms Editor UI ControlForms and Dialogs UI ControlWinForms GridView UI ControlWinForms ListView UI ControlWinForms Menu UI ControlWinForms ComboBox UI ControlWinForms PageView UI ControlPanels and Labels UI ControlWinForms Panorama UI ControlWinForms PDFViewer UI ControlWinForms Property Grid UI ControlWinForms Ribbon UI ControlWinForms PivotGrid UI ControlWinForms RichTextBox UI ControlGet Started in C#RichTextBox - SettingsDocument ElementsContentsSectionParagraphSpanHyperlinkInline ImageTableBookmarksRichTextBox - FeaturesLayout ModesSelectionSearchPositionRead OnlyFormat APIImport & ExportImport & Export - SettingsHTML SupportSpell CheckKeyboard SupportWinForms Rotator UI ControlWinForms Scheduler UI ControlWinForms Shortcuts UI ControlWinForms SpellChecker UI ControlWinForms Track & Status UI ControlWinForms TreeView UI ControlWinForms Wizard UI ControlWinForms Test UI ControlWinForms Theme UI Control |