This repository has been archived by the owner on Oct 2, 2023. It is now read-only.
/
Form1.cs
58 lines (55 loc) · 2.44 KB
/
Form1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using DevExpress.Utils.Svg;
using DevExpress.XtraReports.Design;
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.UserDesigner;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Customize_the_Property_Grid_in_the_Report_Designer
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
XtraReport.FilterComponentProperties += XtraReport_FilterComponentProperties;
}
private void simpleButton1_Click(object sender, EventArgs e)
{
XtraReport report = new XtraReport1();
ReportDesignTool designTool = new ReportDesignTool(report);
designTool.DesignRibbonForm.DesignMdiController.DesignPanelLoaded += ReportDesigner1_DesignPanelLoaded;
designTool.ShowRibbonDesignerDialog();
}
private void XtraReport_FilterComponentProperties(object sender, FilterComponentPropertiesEventArgs e)
{
PropertyDescriptor propertyDescriptor1 = e.Properties["PaperKind"] as PropertyDescriptor;
if (propertyDescriptor1 != null)
{
List<Attribute> attributes = new List<Attribute>(propertyDescriptor1.Attributes.Cast<Attribute>().Where(att => !(att is PropertyGridTabAttribute)));
attributes.Add(new PropertyGridTabAttribute("My tab"));
e.Properties["PaperKind"] = TypeDescriptor.CreateProperty(
propertyDescriptor1.ComponentType,
propertyDescriptor1,
attributes.ToArray());
}
}
private void ReportDesigner1_DesignPanelLoaded(object sender, DevExpress.XtraReports.UserDesigner.DesignerLoadedEventArgs e)
{
// Access the tab icon provider
IPropertyGridIconsProvider propertyGridImagesProvider = (IPropertyGridIconsProvider)e.DesignerHost.GetService(typeof(IPropertyGridIconsProvider));
// Assign an svg icon to the "My tab" tab if it does not have any
if (!propertyGridImagesProvider.Icons.ContainsKey("My tab"))
{
SvgImage customTabIcon = SvgImage.FromFile(@"..\..\CustomTabIcon.svg");
propertyGridImagesProvider.Icons.Add("My tab", new IconImage(customTabIcon));
}
}
}
}