When the ShowTagsInputDialog property is set to True, the Tags dialog box is shown just before the document is generated. You can programmatically show that dialog whenever you want (and independently of the value of the ShowTagsInputDialog property) by calling the EditTags method.
For example, the following code shows the tags input dialog box when a button is clicked:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Public Class Form1 Dim doc As New C1PrintDocument() Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.C1PrintPreviewControl1.Document = doc ' Create tags to be shown. doc.Tags.Add(New C1.C1Preview.Tag("Statement", "Hello World!")) doc.Tags("Statement").ShowInDialog = True doc.Tags.Add(New C1.C1Preview.Tag("Name", "ComponentOne")) doc.Tags.Add(New C1.C1Preview.Tag("Location", "Pittsburgh, PA")) ' Add tags to the document. 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) End Sub Private Sub EditTagsNow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EditTagsNow.Click ' Show the Tags dialog box on button click. doc.ShowTagsInputDialog = True doc.EditTags() End Sub Private Sub GenerateDocNow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GenerateDocNow.Click doc.ShowTagsInputDialog = False ' Generate the document on button click. doc.Generate() End Sub End Class |
To write code in C#
C# |
Copy Code
|
---|---|
public partial class Form1 : Form { public Form1() { InitializeComponent(); } C1PrintDocument doc = new C1PrintDocument(); private void Form1_Load(object sender, EventArgs e) { this.c1PrintPreviewControl1.Document = doc; // Create tags to be shown. doc.Tags.Add(new C1.C1Preview.Tag("Statement", "Hello World!")); doc.Tags["Statement"].ShowInDialog = true; doc.Tags.Add(new C1.C1Preview.Tag("Name", "ComponentOne")); doc.Tags.Add(new C1.C1Preview.Tag("Location", "Pittsburgh, PA")); // Add tags to the document. 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); } private void EditTagsNow_Click(object sender, EventArgs e) { // Show the Tags dialog box on button click. doc.ShowTagsInputDialog = true; doc.EditTags(); } private void GenerateDoc_Click(object sender, EventArgs e) { doc.ShowTagsInputDialog = false; // Generate the document on button click. doc.Generate(); } } |
In the example above, the Tags dialog box will appear when the EditTagsNow button is clicked.