翻譯|使用教程|編輯:王香|2018-08-28 10:50:06.000|閱讀 538 次
概述:本文主要講解在Stimulsoft中如何使用自動(dòng)更新的實(shí)時(shí)報(bào)表預(yù)覽。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
【下載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;
...
接下來(lái),由于圖表示例有兩個(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é)果如下圖所示:

本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@ke049m.cn