文檔首頁(yè)>>Stimulsoft Reports.WinForms教程-2019>>【Stimulsoft Reports.WinForms教程】使用自動(dòng)更新的實(shí)時(shí)報(bào)表預(yù)覽
【Stimulsoft Reports.WinForms教程】使用自動(dòng)更新的實(shí)時(shí)報(bào)表預(yù)覽
【下載Stimulsoft Reports.Ultimate最新版本】
此示例構(gòu)建具有自動(dòng)內(nèi)容更新的實(shí)時(shí)實(shí)時(shí)報(bào)表。例如,使用帶有一些文本的報(bào)表和帶有兩個(gè)系列的圖表。在Form1初始化方法中,找到必要的報(bào)表組件,報(bào)表從應(yīng)用程序資源加載:
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定時(shí)器事件改變所選擇的報(bào)表組件(如角度)的屬性,并重繪報(bào)表。首先,應(yīng)用文本輪換:
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; ...
接下來,由于圖表示例有兩個(gè)系列,因此應(yīng)對(duì)每個(gè)系列進(jìn)行旋轉(zhuǎn):
... //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; ...
最后,實(shí)時(shí)更新報(bào)表:
... RectangleD rect = stiPreviewControl1.GetComponentRect(text); stiPreviewControl1.InvalidatePageRect(rect.ToRectangle()); rect = stiPreviewControl1.GetComponentRect(chart); stiPreviewControl1.InvalidatePageRect(rect.ToRectangle()); //stiPreviewControl1.View.Invalidate(); }
示例代碼的結(jié)果如下圖所示: