下面的示例演示了在运行时刻如何把有一个新页面的新组添加到 图表向导。
首先,创建一个要作为页面内容的控件。 新建继承自 WizardControlBase 的控件,并把 ChartControl 拖放到其中。 这是紧随其后的,因为页面被设计用于定制图表。 此页面应该包含一个图表控件来显示被改动设置的影响。
然后,使用下列代码创建一个组和一个页面。 可以接管 WizardPage.InitializePage 事件来访问所包含的图表控件。
C# | 复制代码 |
---|---|
using DevExpress.XtraCharts.Wizard; //... private void ShowNewWizard() { // Create a Wizard instance. ChartWizard wiz = new ChartWizard(this.chartControl1); // Create a new group. WizardGroup MyWizardGroup = wiz.RegisterGroup("NewGroup"); // Create a new page with a "MyPage" name, "MyHeader" as a caption, "MyDesription" // as a description, without image. It contains the UserControl1. WizardPage MyWizardPage = MyWizardGroup.RegisterPage(typeof(UserControl1), "MyPage", "MyHeader", "MyDesription", null); // Subscribe to the InitializePage event. MyWizardPage.InitializePage += new InitializePageEventHandler (MyWizardPage_InitializePage); // Invoke the Wizard. wiz.ShowDialog(); } void MyWizardPage_InitializePage(object sender, InitializePageEventArgs e) { e.Chart = ((UserControl1)e.Control).chartControl1; } |
Visual Basic | 复制代码 |
---|---|
Imports DevExpress.XtraCharts.Wizard ' ... Private Sub ShowNewWizard() ' Create a Wizard instance. Dim wiz As New ChartWizard(Me.chartControl1) ' Create a new group. Dim MyWizardGroup As WizardGroup = wiz.RegisterGroup("NewGroup") ' Create a new page with a "MyPage" name, "MyHeader" as a caption, ' "MyDesription" as a description, without image. It contains the UserControl1. Dim MyWizardPage As WizardPage = MyWizardGroup.RegisterPage(GetType(UserControl1), _ "MyPage", "MyHeader", "MyDesription", Nothing) ' Subscribe to the InitializePage event. AddHandler MyWizardPage.InitializePage, AddressOf MyWizardPage_InitializePage ' Invoke the Wizard. wiz.ShowDialog() End Sub Private Sub MyWizardPage_InitializePage(ByVal sender As Object, ByVal e As InitializePageEventArgs) e.Chart = DirectCast(e.Control, UserControl1).chartControl1 End Sub |