Note注意

重要说明: .NET Client Profile Framework 不支持此功能。 要在最终用户的机器上使用此功能,则必须安装完整的 .NET Framework。 更多信息,请参阅 Windows 窗体部署 文档中的 关于 .NET Framework 4.0 Client Profile 的重要说明 小节。

这个示例展示了如何隐藏 最终用户设计器 的属性网格中的某些属性。 要这样做,则接管 XtraReport.FilterControlProperties 静态事件,并为属性网格定义筛选规则。

例如,下列代码演示了如何隐藏 XRControl.Scripts 属性 (对所有报表元素隐藏)、SubreportBase.ReportSource 属性 (对所有子报表隐藏)、 XRControl.NameXRControl.DataBindings 属性 (对特定标签隐藏)。

C#CopyCode image复制代码
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.UserDesigner;
// ...

static void Main() 
{
    // Handle the static FilterControlProperties event 
    // to define filtering rules for the Property Grid.
    XtraReport.FilterControlProperties += 
        new FilterControlPropertiesEventHandler(OnFilterControlProperties);

    Application.Run(new Form1());
}

private void button1_Click(object sender, System.EventArgs e) {
    // Create a report of the XtraReport1 type and invoke its End-User Designer.
    XtraReport1 report = new XtraReport1();
    report.ShowDesigner();
}

static void OnFilterControlProperties(object sender, FilterControlPropertiesEventArgs e) {
    // If you wish to hide the scripting ability in the End-User Designer,
    // just remove the Scripts property for all report elements.
    e.Properties.Remove("Scripts");

    // If you wish subreports to always show the predefined reports,
    // you may hide the ReportSource property.
    if (e.Control is XRSubreport) {
        e.Properties.Remove("ReportSource");
    }

    // The following code hides the Name and DataBindings properties
    // for the xrLabel1 in XtraReport1.
    if (sender is XtraReport1 && e.Control.Name == "xrLabel1") {
        e.Properties.Remove("Name");
        e.Properties.Remove("DataBindings");
    }
}
Visual BasicCopyCode image复制代码
Imports DevExpress.XtraReports.UI
Imports DevExpress.XtraReports.UserDesigner
' ...


' NOTE: To make this code work, set the "Startup object" option 
' to "Sub Main" in the General properties of your project.
<STAThread()> Shared Sub Main()
    ' Handle the static FilterControlProperties event 
    ' to define filtering rules for the Property Grid.
    AddHandler XtraReport.FilterControlProperties, AddressOf OnFilterControlProperties

    Application.Run(New Form1())
End Sub


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
    ' Create a report of the XtraReport1 type and invoke its End-User Designer.
    Dim report As New XtraReport1()
    report.ShowDesigner()
End Sub

Shared Sub OnFilterControlProperties(ByVal sender As System.Object, ByVal e As _
FilterControlPropertiesEventArgs)
    ' If you wish to hide the scripting ability in the End-User Designer,
    ' just remove the Scripts property for all report elements.
    e.Properties.Remove("Scripts")

    ' If you wish subreports to always show the predefined reports,
    ' you may hide the ReportSource property.
    If TypeOf e.Control Is XRSubreport Then
        e.Properties.Remove("ReportSource")
    End If

    ' The following code hides the Name and DataBindings properties
    ' for the xrLabel1 in XtraReport1.
    If TypeOf sender Is XtraReport1 And e.Control.Name = "XrLabel1" Then
        e.Properties.Remove("Name")
        e.Properties.Remove("DataBindings")
    End If
End Sub

Expand image参阅