Loading text documents from a file is performed with the LoadFromFile method of the NRichTextView object for example:
Loading a Text Document from File |
Copy Code
|
---|---|
richTextView.LoadFromFile(@"C:\MyDocument.docx");
|
When you use this method the control will automatically detect the format of the document and if it supports it will be loaded inside the view. In case you want to load a text document in a specific format you can use the override of this method that accepts a text format object:
Loading a Text Document from File |
Copy Code
|
---|---|
richTextView.LoadFromFile(@"C:\MyDocument.docx", NTextFormat.Docx);
|
You can also load a document from a file asynchronously, which will show a loader over the rich text view while the document is loading. This is useful when working with large documents.
Asynchronious Loading from File |
Copy Code
|
---|---|
richTextView.LoadFromFileAsync(@"C:\MyDocument.docx");
|
If you want to be notified when the document has been loaded, you should subscribe to the DocumentLoaded event of the rich text view.