翻譯|使用教程|編輯:王香|2018-08-28 10:50:06.000|閱讀 520 次
概述:本文主要講解在Stimulsoft中如何使用自動更新的實時報表預覽。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
【下載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(); }
示例代碼的結果如下圖所示:
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn