Introduction
Microsoft Visual Basic versions 6.0 and 5.0 provide an OLE container control for embedding OLE objects directly on forms. The OLE container control provides a means for embedding OLE objects such as Microsoft Excel workbooks, Microsoft PowerPoint presentations, and Microsoft Word documents.
But Visual Studio .NET does not provide an OLE container control for Windows Forms: http://support.microsoft.com/kb/304562/. Microsoft
recommends achieving a similar functionality by using the Microsoft WebBrowser
control to host the document if the document uses ActiveX. Excel, PowerPoint, and Word all support ActiveX. Therefore, documents from those sources may be displayed by using the
WebBrowser
control.
But the WebBrowser
control doesn't embed Office documents because of security problems.
The PreviewContainer
control solves this problem.
Possibilities:
- preview MS Office documents (Excel, Word, PowerPoint and etc)
- preview and zooming different image formats like .jpg, .bmp and etc
- preview and browsing multi-paged
.tif files
- preview file formats which
WebBrowser
control support like
.htm, .xml, and etc. - developers can extend
PreviewContainer
control for support different file formats
Screenshots
Excel document preview:
Multipages TIFF preview:
Background
Solution is based on preview handlers mechanism:
Using the code
Using of this control is very simple:
- Add
a reference to PreviewsHandlers.dll
- Drop the
PreviewContainer
on a Windows Form - Call the
CreateLink
method of the control with the full file path:
this.previewContainer.CreateLink(@"c:\test.tif");
- If you want to browse multi-paged content (like multi-page tif), you can use
these methods:
((IPaginalPreviewHandlerHost)this.previewContainer).PreviousPage();
((IPaginalPreviewHandlerHost)this.previewContainer).NextPage();