* Reset branch for WPF changes * Convert BMP to PNG; fix link-out-of-scope err * Add snippets for WPF... 6794 files!!!! * Add missing snippets * update file updated between migration * Fix paths to include * update breadcrumb and toc * fix index links * fix index links * fix index links * fix markdown
1.8 KiB
title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | ||||
|---|---|---|---|---|---|---|---|---|
| Change Selection in a RichTextBox Programmatically | 03/30/2017 |
|
|
f1213205-1ad7-4cd2-b115-460173cc5aa3 |
Change Selection in a RichTextBox Programmatically
This example shows how to programmatically change the current selection in a xref:System.Windows.Controls.RichTextBox. This selection is the same as if the user had selected the content by using the user interface.
Example
The following [!INCLUDETLA#tla_xaml] code describes a named xref:System.Windows.Controls.RichTextBox control with simple content.
[!code-xamlRichTextBoxMiscSnippets_snip#ChangeSelectionProgrammaticalyExampleWholePage]
Example
The following code programmatically selects some arbitrary text when the user clicks inside the xref:System.Windows.Controls.RichTextBox.
[!code-csharpRichTextBoxMiscSnippets_snip#ChangeSelectionProgrammaticalyCodeExampleWholePage] [!code-vbRichTextBoxMiscSnippets_snip#ChangeSelectionProgrammaticalyCodeExampleWholePage]