Files
docs-desktop/dotnet-desktop-guide/framework/wpf/controls/how-to-save-load-and-print-richtextbox-content.md
T
Pooja Poojari a606313314 US-1889327: Header fixes (#1319)
* Metadata updates for US-1889327.

* H2 edits.

* Updated column header.

* Minor edits.

* Review edits.
2022-02-28 08:53:24 -08:00

36 lines
1.7 KiB
Markdown

---
title: "How to: Save, Load, and Print RichTextBox Content"
ms.date: "03/30/2017"
ms.custom: devdivchpfy22
description: Learn how to Save, Load, and Print RichTextBox content.
dev_langs:
- "csharp"
- "vb"
helpviewer_keywords:
- "saving RichTextBox controls [WPF]"
- "printing RichTextBox controls [WPF]"
- "loading RichTextBox controls [WPF]"
- "RichTextBox control [WPF], saving"
- "RichTextBox control [WPF], printing"
- "RichTextBox control [WPF], loading"
ms.assetid: ffb113d3-c68a-47ca-8ac0-882283f38326
---
# How to: Save, Load, and Print RichTextBox Content
The following example shows how to save content of a <xref:System.Windows.Controls.RichTextBox> to a file, load that content back into the <xref:System.Windows.Controls.RichTextBox>, and print the contents.
## Markup for Save, Load, and Print RichTextBox Content
Below is the markup for the example.
[!code-xaml[RichTextBoxMiscSnippets_snip#SaveLoadPrintRTBExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/RichTextBoxMiscSnippets_snip/CSharp/SaveLoadPrintRTB.xaml#saveloadprintrtbexamplewholepage)]
## Code for Save, Load, and Print RichTextBox Content
Below is the code behind for the example.
[!code-csharp[RichTextBoxMiscSnippets_snip#SaveLoadPrintRTBCodeExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/RichTextBoxMiscSnippets_snip/CSharp/SaveLoadPrintRTB.xaml.cs#saveloadprintrtbcodeexamplewholepage)]
[!code-vb[RichTextBoxMiscSnippets_snip#SaveLoadPrintRTBCodeExampleWholePage](~/samples/snippets/visualbasic/VS_Snippets_Wpf/RichTextBoxMiscSnippets_snip/VisualBasic/SaveLoadPrintRTB.xaml.vb#saveloadprintrtbcodeexamplewholepage)]
## See also
- [RichTextBox Overview](richtextbox-overview.md)
- [TextBox Overview](textbox-overview.md)