A hyperlink to an external file differs from a link to an external anchor by the link target. The link target class for an external file link is called C1LinkTargetFile. Clicking such a link will use the Windows shell to open that file. For instance, if in the sample from the preceding section, you replace the line creating the external anchor link target with the following line:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Dim linkTarget = New C1.C1Preview.C1LinkTargetFile("c:\") |
To write code in C#
C# |
Copy Code
|
---|---|
C1LinkTarget linkTarget = new C1LinkTargetFile(@"c:\"); |
Clicking on that link will open the Windows Explorer on the root directory of the C: drive.
Again, here is a complete program:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
' Make document with a hyperlink to external file. Dim doc As New C1.C1Preview.C1PrintDocument Dim rt As New C1.C1Preview.RenderText("Explore drive C:...") Dim linkTarget As C1.C1Preview.C1LinkTarget = New C1.C1Preview.C1LinkTargetFile("c:\") rt.Hyperlink = New C1.C1Preview.C1Hyperlink(linkTarget) doc.Body.Children.Add(rt) doc.Generate() ' Show document with hyperlink in preview. Dim preview As New C1.Win.C1Preview.C1PrintPreviewDialog() preview.Document = doc preview.ShowDialog() |
To write code in C#
C# |
Copy Code
|
---|---|
// Make document with a hyperlink to external file. C1PrintDocument doc = new C1PrintDocument(); RenderText rt = new RenderText("Explore drive C:..."); C1LinkTarget linkTarget = new C1LinkTargetFile(@"c:\"); rt.Hyperlink = new C1Hyperlink(linkTarget); doc.Body.Children.Add(rt); doc.Generate(); // Show document with hyperlink in preview. C1PrintPreviewDialog preview = new C1PrintPreviewDialog(); preview.Document = doc; preview.ShowDialog(); |