原創(chuàng)|其它|編輯:郝浩|2012-05-21 01:25:05.000|閱讀 777 次
概述:本教程演示了,如何在DevExpress XtraCharts ASPxCallbackPanel回調(diào)時如何完成WebChartControl的添加。首先創(chuàng)建一個新的ASP.NET Web應(yīng)用程序(Visual Studio 2008或2010),或打開一個現(xiàn)有的。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
本教程演示了,如何在DevExpress XtraCharts ASPxCallbackPanel回調(diào)時如何完成WebChartControl的添加。
1、創(chuàng)建一個新的ASP.NET Web應(yīng)用程序(Visual Studio 2008或2010),或打開一個現(xiàn)有的。
2、將所需的程序集添加到項目中。
注意:如果你喜歡,控件也可以自動添加(拖放一個WebChartControl實例到頁面中),這會影響你的web應(yīng)用程序的Web.config文件。關(guān)于這些變化的更多信息,請參閱。
3、切換到Default.aspx頁面的設(shè)計視圖,從DX.11.2:公共控件工具欄拖放一個ASPxButton到頁面中。處理它的Click事件,生成一個Web圖表。
4、然后,按一下按鈕的智能標(biāo)簽。在調(diào)用操作列表,禁用AutoPostBack屬性,并單擊客戶端事件......鏈接。
在調(diào)用對話框中,從客戶端的Click事件處理程序,調(diào)用回調(diào)面板PerformCallback()。
申請更改,單擊"確定"退出對話框。
5、現(xiàn)在,從DX.11.2:導(dǎo)航和布局工具欄拖放ASPxCallbackPanel到頁面上。
6、設(shè)置其ClientInstanceName面板,并以下列方式處理回調(diào)事件。
using System; using DevExpress.XtraCharts; using DevExpress.XtraCharts.Web; using DevExpress.Web.ASPxClasses; using DevExpress.Web.ASPxCallbackPanel; // ... protected void ASPxCallbackPanel1_Callback(object sender, CallbackEventArgsBase e) { WebChartControl wbc = new WebChartControl(); wbc.Series.Add(new Series("Series", ViewType.Line)); wbc.Series[0].ArgumentScaleType = ScaleType.DateTime; wbc.Series[0].ValueScaleType = ScaleType.Numerical; Random r = new Random(); for (int i = 0; i < 5; i++) { wbc.Series[0].Points.Add(new SeriesPoint(DateTime.Today.AddDays(i), ((int)((r.NextDouble() * 100) * 10)) / 10.0)); } wbc.Width = ((ASPxCallbackPanel)sender).Width; ((ASPxCallbackPanel)sender).Controls.Add(wbc); }VB源碼:
Imports System Imports DevExpress.XtraCharts Imports DevExpress.XtraCharts.Web Imports DevExpress.Web.ASPxClasses Imports DevExpress.Web.ASPxCallbackPanel ' ... Protected Sub ASPxCallbackPanel1_Callback(ByVal sender As Object, _ ByVal e As CallbackEventArgsBase) Dim wbc As New WebChartControl() wbc.Series.Add(New Series("Series", ViewType.Line)) wbc.Series(0).ArgumentScaleType = ScaleType.DateTime wbc.Series(0).ValueScaleType = ScaleType.Numerical Dim r As New Random() For i As Integer = 0 To 4 wbc.Series(0).Points.Add(New SeriesPoint(DateTime.Today.AddDays(i), _ (CInt(Fix((r.NextDouble() * 100) * 10))) / 10.0)) Next i wbc.Width = (CType(sender, ASPxCallbackPanel)).Width CType(sender, ASPxCallbackPanel).Controls.Add(wbc) End Sub
運行應(yīng)用程序,并查看結(jié)果。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@ke049m.cn
文章轉(zhuǎn)載自: