|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionI recently developed an application with quite a few standard reports. The reports all have a set selection criteria, and didn't need filtering, so no front end was necessary - just straight to the report. I tried the I, therefore, needed a common method to replicate the Using the codeThere is an example form included in the source which should hopefully expand and illustrate these instructions. The In the properties of the
You will need a class variable for the private System.Windows.Forms.PrintPreviewControl preview
For the this.ucPrintBar1.PrintPropertiesChanged +=
new printPropertiesChanged(this.ucPrintBar1_PrintPropertiesChanged);
with the following functions: private void ucPrintBar1_PrintPropertiesChanged()
{
//If the the print properties change (orientation, margins etc)
// we need to re-create the report with the new parameters.
this.Controls.Remove(this.preview);
this.setupReport();
}
private void setupReport()
{
this.preview = new System.Windows.Forms.PrintPreviewControl();
this.preview.Document = this.printDocument1;
this.preview.Dock = System.Windows.Forms.DockStyle.Fill;
this.preview.Location = new System.Drawing.Point(0, 25);
this.preview.Name = "preview";
this.ucPrintBar1.PreviewControl = this.preview;
this.Controls.Add(this.preview);
this.ucPrintBar1.loadDefaults();
}
The The thing I had most difficulty with was refreshing the print preview after changing the print properties. The obvious things didn't work (calling There you have it - all you have to do now is create the report itself. A note on the ucFormManagement componentI like to have my forms open up with the same size and position as when I last used it. It irritates me when I have to resize a form every time I use it (and I know quite a few other people who think the same way). So, all my applications use my That's the automatic stuff. I also have the ability to manually store the form information if I need to. The component has a this.ucFormManagement1.addExtra("LeftMargin",
this.document.DefaultPageSettings.Margins.Left);
Here's an example of how to retrieve the additional form information: if (this.ucFormManagement1.Extras != null)
{
if (this.ucFormManagement1.Extras.ContainsKey("LeftMargin"))
{
leftMargin =
Convert.ToInt32(this.ucFormManagement1.Extras["LeftMargin"]);
}
}
History
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||