Some of the best practices to follow while working with the components and controls in the PrintPreview library such as PrintPreviewControl, PreviewPane, PreviewThumbnailView, PreviewOutlineView, PreviewTextSearchPanel and PrintPreviewDialog are listed below:
You may want to customize a toolbar in the PrintPreviewControl control by adding a custom button. To add your own toolbar button to any of the built-in toolbars on the PrintPreviewControl, add a PrintPreviewControl to the form, and complete the following steps:
Once you have added the toolbar button, you can customize its actions. You can now add a Click event handler to the button or further customize its properties.
To change the default processing of a built-in toolbar button on a PrintPreviewControl you need to handle the preview pane's UserAction event.
Add the PrintPreviewControl to the form, and complete the following steps:
The handler receives an instance of UserActionEventArgs which contains two interesting properties: PreviewAction and Cancel. PreviewAction is an enum listing all supported user events, such as file open, print, and so on. Testing that property you may find the action you're interested in. The other important property of UserActionEventArgs is Cancel - if you add your own processing to an action and want to omit the standard processing, set UserActionEventArgs.Cancel to True, otherwise standard processing will take place after your event handler returns.
To monitor interesting preview related properties, use the PropertyChanged event on the C1PreviewPane object within the C1PrintPreviewControl. All of the preview pane's own properties (not inherited from its base control) fire the PropertyChanged event when their values change.
For instance, the following code will add a handler to the PropertyChanged event provided that your form includes the PrintPreviewControl:
C# |
コードのコピー
|
---|---|
this.c1PrintPreviewControl1.PreviewPane.PropertyChanged += new PropertyChangedEventHandler(PreviewPane_PropertyChanged); |
The following property changed event handler will print a debug line each time the current page changes in the preview for whatever reason:
C# |
コードのコピー
|
---|---|
void PreviewPane_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "StartPageIdx") Debug.WriteLine("Current page changed to " + this.c1PrintPreviewControl1.PreviewPane.StartPageIdx.ToString()); } |