$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
RichTextBox Control for WinForms
Edit rich text content with text formatting options, mail-merge, table, and floating objects, etc.
Home > WinForms UI Controls > User Manual > RichTextBox Import and Export in C#

C# Import and Export Content in RichTextBox

KetticRichTextBox WinForms control is capable of exporting and importing content from the .NET component. This feature allows your application to save or load the input of users to or from the data base. It is also possible to save and load the RichTextBox content to or from a file. KetticRichTextBox .NET component contains the C# class, which implements the FormatProviders.IDocumentFormatProvider, to achieve this functionality.

Import/Export Various Document Formats using KetticRichTextBox

KetticRichTextBox control built in the C# classes, by which the users can import and export the content of KetticRichTextBox to/from a variety of document formats, into the DocumentFormatProvider.
  • HTML, KetticRichTextBox control provides the HtmlFormatProvider C# class, included in the Kettic.WinForms.RichTextBox.FileFormats.Html namespace, to import and export content of KetticRichTextBox to/from HTML documents.
  • DOCX, KetticRichTextBox .NET component provides the DocxFormatProvider C# class, included in the Kettic.WinForms.RichTextBox.FileFormats.OpenXml.Docx namespace, to import and export content of KetticRichTextBox to/from DOCX documents.
  • Plain text, the TxtFormatProvider C# class, included in the Kettic.WinForms.RichTextBox.FormatProviders.Txt namespace, is used to import and export content of KetticRichTextBox to/from plain text.
  • PDF, the PdfFormatProvider C# class included in the Kettic.WinForms.RichTextBox.FileFormats.Pdf namespace, is used to export content of KetticRichTextBox to PDF document.
  • RTF, the RtfFormatProvider C# class, included in the Kettic.WinForms.RichTextBox.FileFormats.Rtf namespace, is used to import and export content of KetticRichTextBox to/from RTF documents.
  • XAML, KetticRichTextBox component contains the XamlFormatProvider C# class to import and export content of KetticRichTextBox XAML documents. This C# class is included in the Kettic.WinForms.RichTextBox.FileFormats.Xaml namespace.

C# Export to Xaml from KetticRichTextBox

The following C# code snippet shows how to export content of KetticRichTextBox to string in a Xaml document format.

public string ExportToXAML(KetticDocument document)
{
XamlFormatProvider provider = new XamlFormatProvider();
return provider.Export(document);
}

C# Export to Docx File from KetticRichTextBox

The following C# code snippet demonstrates how to export content of KetticRichTextBox to a Docx document file format.

public void ExportToDocx(KetticDocument document)
{
DocxFormatProvider provider = new DocxFormatProvider();
SaveFileDialog saveDialog = new SaveFileDialog();
saveDialog.DefaultExt = ".docx";
saveDialog.Filter = "Documents|*.docx";
DialogResult dialogResult = saveDialog.ShowDialog();
if (dialogResult == System.Windows.Forms.DialogResult.OK)
{
using (Stream output = saveDialog.OpenFile())
{
provider.Export(document, output);
MessageBox.Display("Done!");
}
}
}

C# Import from Xaml for KetticRichTextBox

The following C# code snippet demonstrates how to import content of KetticRichTextBox from a Xaml document.

public KetticDocument ImportXaml(string content)
{
XamlFormatProvider provider = new XamlFormatProvider();
return provider.Import(content);
}

C# Import from Docx for KetticRichTextBox

The following C# code snippet demonstrates how to import content of KetticRichTextBox from a Docx document.

public KetticDocument ImportDocx()
{
KetticDocument document = null;
IDocumentFormatProvider provider = new DocxFormatProvider();
OpenFileDialog openDialog = new OpenFileDialog();
openDialog.Filter = "Documents|*.docx";
openDialog.Multiselect = false;
DialogResult dialogResult = openDialog.ShowDialog();
if (dialogResult == System.Windows.Forms.DialogResult.OK)
{
using (FileStream stream = new FileStream(openDialog.FileName, FileMode.Open))
{
document = provider.Import(stream);
}
}
return document;
}
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls