Reports for WinForms | ComponentOne
Working with C1PrintDocument / Expressions, Scripts, Tags / Editing Tag Values at Run Time / Displaying Specific Tags
In This Topic
    Displaying Specific Tags
    In This Topic

    When the ShowTagsInputDialog property is set to True all tags are displayed by default in the Tags dialog box. You can prevent users from editing specific tags by using the Tag.ShowInDialog property. To let users edit some but not all tags, set the Flags property to None on tags you do not want to be edited.

    For example, the following code in the Form_Load event adds three tags to the document, one of which cannot be edited:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Dim doc As New C1PrintDocument()
    Me.C1PrintPreviewControl1.Document = doc
    ' Show the Tags dialog box on document generation.
    doc.ShowTagsInputDialog = True
    ' Create a tag but do not show it in the Tags dialog box.
    doc.Tags.Add(New C1.C1Preview.Tag("Statement", "Hello World!"))
    doc.Tags("Statement").ShowInDialog = False
    ' Create tags that will be shown.
    doc.Tags.Add(New C1.C1Preview.Tag("Name", "ComponentOne"))
    doc.Tags.Add(New C1.C1Preview.Tag("Location", "Pittsburgh, PA"))
    ' Add tags to the document and generate.
    Dim rt As New C1.C1Preview.RenderText()
    rt.Text = "[Statement] My name is [Name] and my current location is [Location]."
    doc.Body.Children.Add(rt)
    doc.Generate()
    

    To write code in C#

    C#
    Copy Code
    C1PrintDocument doc = new C1PrintDocument();
    this.c1PrintPreviewControl1.Document = doc;
    // Show the Tags dialog box on document generation.
    doc.ShowTagsInputDialog = true;
    // Create a tag but do not show it in the Tags dialog box.
    doc.Tags.Add(new C1.C1Preview.Tag("Statement", "Hello World!"));
    doc.Tags["Statement"].ShowInDialog = false;
    // Create tags that will be shown.
    doc.Tags.Add(new C1.C1Preview.Tag("Name", "ComponentOne"));
    doc.Tags.Add(new C1.C1Preview.Tag("Location", "Pittsburgh, PA"));
    // Add tags to the document and generate.
    C1.C1Preview.RenderText rt = new C1.C1Preview.RenderText();
    rt.Text = "[Statement] My name is [Name] and my current location is [Location].";
    doc.Body.Children.Add(rt);
    doc.Generate();
    

    When the application is run, the following dialog box is displayed before the document is generated:

    Changing the text in any of the textboxes in the Tags dialog box will change the text that appears in the generated document. Note that the Statement tag is not displayed, and can not be changed from the dialog box. If the default text is left, the following willproduce the following text in the generated document:

    Hello World! My name is ComponentOne and I'm currently located in Pittsburgh, PA.