Skip to main content
A newer version of this page is available. .

How to: Create Parameter

The following example demonstrates how to create the report parameter in the Snap Report API.

  1. Call the IRichEditDocumentServer.LoadDocumentTemplate method to load the document template and open it for modification by calling the SubDocument.BeginUpdate method.
  2. Create a new Parameter instance that is the new report parameter.
  3. To set the parameter’s name, type and value, use the Parameter.Name, Parameter.Type and Parameter.Value properties.
  4. Add the created object to the document’s parameters collection, accessible through the SnapDocument.Parameters property.
  5. Finalize the modification by calling the SubDocument.EndUpdate method.
server.LoadDocumentTemplate("Template.snx")
server.Document.BeginUpdate()
'Create parameter:
Dim param1 As New Parameter()
param1.Name = "Region"
param1.Type = GetType(System.String)
param1.Value = "NEW ENGLAND"
server.Document.Parameters.Add(param1)
'Insert parameter field in the document:
Dim list As SnapList = server.Document.FindListByName("Data Source 11")
server.Document.ParseField(list.Field)
list.BeginUpdate()
list.ListHeader.InsertText(list.ListHeader.Tables(0).FirstRow.Cells.InsertAfter(3).ContentRange.End, "Region")
list.RowTemplate.CreateSnText(list.RowTemplate.Tables(0).FirstRow.Cells.InsertAfter(3).ContentRange.End, "Region \p")
list.Field.Update()
list.EndUpdate()
server.Document.EndUpdate()
server.Document.Fields.Update()