# GrapeCity.ActiveReports.Viewer.Win.Viewer.SetParametersValues

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_SetParametersValues_" data-uid="GrapeCity.ActiveReports.Viewer.Win.Viewer.SetParametersValues*">SetParametersValues Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="GrapeCity_ActiveReports_Viewer_Win_Viewer_SetParametersValues_" data-uid="GrapeCity.ActiveReports.Viewer.Win.Viewer.SetParametersValues*"></a>
<h4 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_SetParametersValues_System_Collections_Generic_IEnumerable_GrapeCity_Viewer_Common_IParameter__" data-uid="GrapeCity.ActiveReports.Viewer.Win.Viewer.SetParametersValues(System.Collections.Generic.IEnumerable{GrapeCity.Viewer.Common.IParameter})">SetParametersValues(IEnumerable&lt;IParameter&gt;)</h4>
<div class="markdown level1 summary"><p>Sets values for the parameters of the currently displayed report in the Viewer.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void SetParametersValues(IEnumerable&lt;IParameter&gt; parameters)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1">IEnumerable</a>&lt;<a class="xref" href="../MESCIUS.ActiveReports.Viewer.Common/GrapeCity.Viewer.Common.IParameter.html">IParameter</a>&gt;</td>
      <td><span class="parametername">parameters</span></td>
      <td><p>A collection of <a class="xref" href="../MESCIUS.ActiveReports.Viewer.Common/GrapeCity.Viewer.Common.IParameter.html">IParameter</a> objects representing the parameters of the report and their respective values to be set.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_SetParametersValues_System_Collections_Generic_IEnumerable_GrapeCity_Viewer_Common_IParameter___remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method allows for dynamic modification of report parameters at runtime. By providing a collection of <a class="xref" href="../MESCIUS.ActiveReports.Viewer.Common/GrapeCity.Viewer.Common.IParameter.html">IParameter</a> objects,
you can adjust the data or the appearance of the report based on user input, application state, or other criteria.
It's important to ensure that the names of the parameters provided match exactly with those defined in the report.
Mismatched parameter names will not be recognized by the report and, as a result, will not affect the report's output.</p>
</div>
<h5 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_SetParametersValues_System_Collections_Generic_IEnumerable_GrapeCity_Viewer_Common_IParameter___examples">Examples</h5>
<pre><code class="lang-csharp">public class ParameterAdapter : IParameter
{
	private string _name;
	private IEnumerable&lt;object&gt; _values;
	public ParameterAdapter(string name, IEnumerable&lt; object&gt; values)
	{
		_name = name;
		_values = values ?? throw new ArgumentNullException(nameof(values), "Values cannot be null.");
	}
	public string Name
	{
		get =&gt; _name;
		set =&gt; _name = value ?? throw new ArgumentNullException(nameof(value), "Name cannot be null.");
	}
	public IEnumerable&lt;object&gt; Values
	{
		get =&gt; _values;
		set =&gt; _values = value ?? throw new ArgumentNullException(nameof(value), "Values cannot be null.");
	}
}
// Handler for a UI control event, e.g., a button click
private void OnUpdateReportParametersClick(object sender, EventArgs e)
{
	// Assuming 'viewer' is an instance of the Viewer class
	// Assuming 'startDatePicker' and 'regionComboBox' are UI controls
	// Cast each element of the array to object
	var startDateParameter = new ParameterAdapter("StartDate", new[] { startDatePicker.Value }.Cast &lt;object&gt;());
	// For the region parameter, ensure that the selected item is treated as an object.
	// If regionComboBox.SelectedItem is not null, cast it to object; otherwise, handle the null case appropriately.
	var regionParameterValues = regionComboBox.SelectedItem != null ? new[] { regionComboBox.SelectedItem }.Cast&lt;object&gt;()
	                                                                        : Enumerable.Empty &lt;object&gt;();
	var regionParameter = new ParameterAdapter("Region", regionParameterValues);
	var parameters = new List&lt;IParameter&gt; { startDateParameter, regionParameter };
	// Dynamically update the report with new parameters
	viewer.SetParametersValues(parameters);
}</code></pre>

</div>
