注意 |
---|
重要说明: .NET Client Profile Framework 不支持此功能。 要在最终用户的机器上使用此功能,则必须安装完整的 .NET Framework。 更多信息,请参阅 Windows 窗体部署 文档中的 关于 .NET Framework 4.0 Client Profile 的重要说明 小节。 |
这个示例展示了如何重命名 最终用户设计器 中的 工具箱 项。
要这样做,则接管 XRDesignMdiController.DesignPanelLoaded 事件,从报表设计器获取 System.Drawing.Design.IToolboxService 对象,并按需要定制工具箱项的集合。
下列代码把一个前缀添加到所有工具箱项的名称之前。
C# | 复制代码 |
---|---|
using System; using System.Windows.Forms; using System.Drawing.Design; using DevExpress.XtraReports.UserDesigner; // ... private void button1_Click(object sender, EventArgs e) { // Create a new End-User Designer. XRDesignForm designForm = new XRDesignForm(); // Handle the DesignPanelLoaded event. designForm.DesignMdiController.DesignPanelLoaded += new DesignerLoadedEventHandler(DesignMdiController_DesignPanelLoaded); // Load the report into the designer. designForm.OpenReport(new XtraReport1()); // Show the End-User Designer window. designForm.Show(); } private void DesignMdiController_DesignPanelLoaded(object sender, DesignerLoadedEventArgs e) { // Get the toolbox service. IToolboxService ts = (IToolboxService)e.DesignerHost.GetService(typeof(IToolboxService)); // Get a collection of toolbox items. ToolboxItemCollection coll = ts.GetToolboxItems(); // Iterate through toolbox items. foreach (ToolboxItem item in coll) { // Add the "Cool" prefix to all toolbox item names. item.DisplayName = "Cool " + item.DisplayName; } } |
Visual Basic | 复制代码 |
---|---|
Imports System Imports System.Windows.Forms Imports System.Drawing.Design Imports DevExpress.XtraReports.UserDesigner ' ... Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click ' Create a new End-User Designer. Dim designForm As New XRDesignForm() ' Handle the DesignPanelLoaded event. AddHandler designForm.DesignMdiController.DesignPanelLoaded, _ AddressOf DesignMdiController_DesignPanelLoaded ' Load the report into the designer. designForm.OpenReport(New XtraReport1()) ' Show the End-User Designer window. designForm.Show() End Sub Private Sub DesignMdiController_DesignPanelLoaded(ByVal sender As Object, _ ByVal e As DesignerLoadedEventArgs) ' Get the toolbox service. Dim ts As IToolboxService = _ CType(e.DesignerHost.GetService(GetType(IToolboxService)), IToolboxService) ' Get a collection of toolbox items. Dim coll As ToolboxItemCollection = ts.GetToolboxItems() ' Iterate through toolbox items. For Each item As ToolboxItem In coll ' Add the "Cool" prefix to all toolbox item names. item.DisplayName = "Cool " & item.DisplayName Next item End Sub |
Show Me |
---|
在 DevExpress Code Central 数据库中可以找到完整的示例项目,网址是 http://www.devexpress.com/example=E2477。 取决于目标平台类型 (ASP.NET、WinForms 等),可以在线运行本示例,或者下载自动可执行的示例。 |