Reports for WinForms | ComponentOne
Working with C1PrintDocument / Anchors and Hyperlinks / Adding a Hyperlink to an Anchor within the Same Document
In This Topic
    Adding a Hyperlink to an Anchor within the Same Document
    In This Topic

    To link one part of your document to another, you have to do two things:

    To create an anchor on a render object, you can add an element (of the type C1Anchor) to the Anchors collection of that render object. For example, if rt is a RenderTable you can write:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    rt.Anchors.Add(New C1.C1Preview.C1Anchor("anchor1"))
    

    To write code in C#

    C#
    Copy Code
    rt.Anchors.Add(new C1Anchor("anchor1"));
    

    This will define an anchor with the name anchor1 (the name used to reference the anchor) on the render table.

    To link another render object, for example a RenderText, to that anchor, you can write:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Dim rtxt As New C1.C1Preview.RenderText()
    rtxt.Text = "Link to anchor1"
    rtxt.Hyperlink = New C1.C1Preview.C1Hyperlink("anchor1")
    

    To write code in C#

    C#
    Copy Code
    RenderText rtxt = new RenderText();
    rtxt.Text = "Link to anchor1";
    rtxt.Hyperlink = new C1Hyperlink("anchor1");
    

    Of course, you must add both involved render objects (the one containing the anchor, and the one with the hyperlink) to the document.

    Hyperlink is a property of the RenderObject class, which is the base class for all render objects, so in exactly the same manner as shown above, any render object may be turned into a hyperlink by setting that property.