下载Stimulsoft Reports Silverlight最新版本

此示例显示如何使用报表变量并在代码中设置其值。有必要在报表中定义变量,然后可以使用变量名称通过代码设置值。首先,使用变量加载报表:

private void btDesign_Click(object sender, System.Windows.RoutedEventArgs e)
{
    var stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("UsingReportVariables.Variables.mrt");
    stiReport1.Load(stream);
    stream.Close();
    stream.Dispose();
    stream = null;
    stiReport1.Design();
}

然后,在btPreview_Click事件中,为报表变量分配新值。您可以使用报表变量名称:

private void btPreview_Click(object sender, System.Windows.RoutedEventArgs e)
{
    viewer.Visibility = System.Windows.Visibility.Visible;
    viewer.Report = null;
 
    var stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("UsingReportVariables.Variables.mrt");
    stiReport1.Load(stream);
    stream.Close();
    stream.Dispose();
    stream = null;
 
    //Set Variables
    stiReport1["Name"] = tbName.Text;
    stiReport1["Surname"] = tbSurname.Text;
    stiReport1["Email"] = tbEmail.Text;
    stiReport1["Address"] = tbAddress.Text;
    stiReport1["Sex"] = rbMale.IsChecked;
    stiReport1["BirthDay"] = dtBirthDay.DisplayDate;
 
    stiReport1.Render();
    viewer.Report = stiReport1;
}

下面的屏幕截图中,您可以看到示例代码的结果。

【Stimulsoft Reports Silverlight教程】在代码中使用报表变量

下载示例

【Stimulsoft Reports Silverlight教程】在代码中使用报表变量

相关文章:

  • 2021-04-05
  • 2021-12-10
  • 2021-08-02
  • 2021-04-19
  • 2021-04-12
  • 2021-08-14
  • 2022-12-23
  • 2021-04-20
猜你喜欢
  • 2021-05-29
  • 2021-04-23
  • 2021-07-31
  • 2021-07-14
  • 2021-06-14
  • 2021-05-17
  • 2021-04-02
相关资源
相似解决方案