发布时间 : 2018-12-12 10:25:03.000|阅读 328 次
概述:此示例显示如何使用报表变量并在代码中设置其值。
相关链接:
下载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正版授权,请点击“咨询在线客服”哟!
渝ICP备12000582号-15/渝公网安备 50010702501010号