文档彩票走势图>>Stimulsoft Reports.WinForms教程-2019>>【Stimulsoft Reports.WinForms教程】使用自动更新的实时报表预览
【Stimulsoft Reports.WinForms教程】使用自动更新的实时报表预览
【下载Stimulsoft Reports.Ultimate最新版本】
此示例构建具有自动内容更新的实时实时报表。例如,使用带有一些文本的报表和带有两个系列的图表。在Form1初始化方法中,找到必要的报表组件,报表从应用程序资源加载:
private StiText text = null; private StiChart chart = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); stiReport1.Render(); StiComponentsCollection comps = stiReport1.RenderedPages[0].GetComponents(); text = comps["Text1"] as StiText; chart = comps["Chart1"] as StiChart; }
所述timer1_Tick定时器事件改变所选择的报表组件(如角度)的属性,并重绘报表。首先,应用文本轮换:
private System.Windows.Forms.Timer timer1; private void timer1_Tick(object sender, System.EventArgs e) { if (text == null)return; //Rotate text float angle = text.TextOptions.Angle; angle -= 1f; if (angle < 0)angle = 359; text.TextOptions.Angle = angle; ...
接下来,由于图表示例有两个系列,因此应对每个系列进行旋转:
... //Rotate series 1 angle = ((StiDoughnutSeries)chart.Series[0]).StartAngle; angle -= 1f; if (angle < 0)angle = 359; ((StiDoughnutSeries)chart.Series[0]).StartAngle = angle; //Rotate series 2 angle = ((StiDoughnutSeries)chart.Series[1]).StartAngle; angle += 1f; if (angle > 359)angle = 0; ((StiDoughnutSeries)chart.Series[1]).StartAngle = angle; ...
最后,实时更新报表:
... RectangleD rect = stiPreviewControl1.GetComponentRect(text); stiPreviewControl1.InvalidatePageRect(rect.ToRectangle()); rect = stiPreviewControl1.GetComponentRect(chart); stiPreviewControl1.InvalidatePageRect(rect.ToRectangle()); //stiPreviewControl1.View.Invalidate(); }
示例代码的结果如下图所示: