using System;
using System.Windows.Forms;
using DevExpress.XtraReports.UserDesigner;
XRDesignMdiController mdiController;
private void button1_Click(object sender, EventArgs e) {
XRDesignForm form = new XRDesignForm();
mdiController = form.DesignMdiController;
mdiController.DesignPanelLoaded +=
new DesignerLoadedEventHandler(mdiController_DesignPanelLoaded);
mdiController.OpenReport(new XtraReport1());
form.ShowDialog();
mdiController.ActiveDesignPanel.CloseReport();
}
void mdiController_DesignPanelLoaded(object sender, DesignerLoadedEventArgs e) {
XRDesignPanel panel = (XRDesignPanel)sender;
mdiController.AddCommandHandler(new SaveCommandHandler(panel));
}
public class SaveCommandHandler : ICommandHandler {
XRDesignPanel panel;
public SaveCommandHandler(XRDesignPanel panel) {
this.panel = panel;
}
public virtual void HandleCommand(ReportCommand command, object[] args, ref bool handled) {
if (!CanHandleCommand(command)) return;
Save();
handled = true;
}
public virtual bool CanHandleCommand(ReportCommand command) {
return command == ReportCommand.SaveFile ||
command == ReportCommand.SaveFileAs ||
command == ReportCommand.Closing;
}
void Save() {
panel.Report.SaveLayout("c:\\report1.repx");
panel.ReportState = ReportState.Saved;
}
}
Yorumlar
Yorum Gönder