-
Notifications
You must be signed in to change notification settings - Fork 2
/
Form1.cs
54 lines (49 loc) · 1.78 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
using DevExpress.DataAccess.Wizard.Services;
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.UserDesigner;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace T119350
{
public partial class Form1 : DevExpress.XtraEditors.XtraForm
{
CustomConnectionStorageService connectionStorageService;
public Form1()
{
InitializeComponent();
connectionStorageService = new CustomConnectionStorageService()
{
FileName = "connections.xml",
IncludeApplicationConnections = true
};
ReplaceService(this.reportDesigner1,
typeof(IConnectionStorageService), connectionStorageService);
this.reportDesigner1.DesignPanelLoaded += DesignMdiControllerOnDesignPanelLoaded;
}
private void ReplaceService(IServiceContainer container,
Type serviceType,
object serviceInstance)
{
if (container.GetService(serviceType) != null)
container.RemoveService(serviceType);
container.AddService(serviceType, serviceInstance);
}
private void DesignMdiControllerOnDesignPanelLoaded(object sender,
DesignerLoadedEventArgs e)
{
ReplaceService(e.DesignerHost, typeof(IConnectionStorageService), connectionStorageService);
}
private void Form1_Load(object sender, EventArgs e)
{
XtraReport report = new XtraReport();
this.reportDesigner1.OpenReport(report);
}
}
}