Working with Report Components

This example shows how to edit some component properties from code. All components of the report are on pages. The pages are in the report object. In order to get a reference to the component object, you must first get a reference to the page. They can be obtained by its name. For example, change text box value in the report:

private void btPreview_Click(object sender, RoutedEventArgs e)
{
viewer.Report = null;

var stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(
"WorkWithReportComponents.Work_with_Components.mrt");
stiReport1.Load(stream);
stream.Close();
stream.Dispose();
stream = null;

((StiText)stiReport1.Pages["Page1"].Components["Text1"]).Text.Value = textBox1.Text;

viewer.Visibility = System.Windows.Visibility.Visible;
stiReport1.Render();
viewer.Report = stiReport1;
}


In the screenshot below you can see the result of the sample code.

Working with Report Components