ComponentOne Reports for WinForms Designer Edition: ComponentOne Reports for WinForms > Working with C1PrintDocument > Anchors and Hyperlinks > Adding a Hyperlink to an External File

Adding a Hyperlink to an External File

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:

      Visual Basic

Dim linkTarget = New C1.C1Preview.C1LinkTargetFile("c:\")

      C#

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:

      Visual Basic

' 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()

      C#

// 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();


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.