添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft Edge More info about Internet Explorer and Microsoft Edge
public ref class PrintPreviewControl : System::Windows::Forms::Control
public class PrintPreviewControl : System.Windows.Forms.Control
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
public class PrintPreviewControl : System.Windows.Forms.Control
type PrintPreviewControl = class
    inherit Control
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type PrintPreviewControl = class
    inherit Control
Public Class PrintPreviewControl
Inherits Control
Inheritance
Object
PrintPreviewControl

Examples

The following code example demonstrates the Document , UseAntiAlias , and Zoom properties of the PrintPreviewControl . To run this example, place the following code in a form and call the InitializePrintPreviewControl method from the form's constructor or Load event-handling method.

internal:
   // Declare the PrintPreviewControl object and the 
   // PrintDocument object.
   PrintPreviewControl^ PrintPreviewControl1;
private:
   System::Drawing::Printing::PrintDocument^ docToPrint;
   void InitializePrintPreviewControl()
      // Construct the PrintPreviewControl.
      this->PrintPreviewControl1 = gcnew PrintPreviewControl;
      // Set location, name, and dock style for PrintPreviewControl1.
      this->PrintPreviewControl1->Location = Point(88,80);
      this->PrintPreviewControl1->Name = "PrintPreviewControl1";
      this->PrintPreviewControl1->Dock = DockStyle::Fill;
      // Set the Document property to the PrintDocument 
      // for which the PrintPage event has been handled.
      this->PrintPreviewControl1->Document = docToPrint;
      // Set the zoom to 25 percent.
      this->PrintPreviewControl1->Zoom = 0.25;
      // Set the document name. This will show be displayed when 
      // the document is loading into the control.
      this->PrintPreviewControl1->Document->DocumentName = "c:\\someFile";
      // Set the UseAntiAlias property to true so fonts are smoothed
      // by the operating system.
      this->PrintPreviewControl1->UseAntiAlias = true;
      // Add the control to the form.
      this->Controls->Add( this->PrintPreviewControl1 );
      // Associate the event-handling method with the
      // document's PrintPage event.
      this->docToPrint->PrintPage += gcnew System::Drawing::Printing::PrintPageEventHandler( this, &Form1::docToPrint_PrintPage );
   // The PrintPreviewControl will display the document
   // by handling the documents PrintPage event
   void docToPrint_PrintPage( Object^ /*sender*/, System::Drawing::Printing::PrintPageEventArgs^ e )
      // Insert code to render the page here.
      // This code will be called when the control is drawn.
      // The following code will render a simple
      // message on the document in the control.
      String^ text = "In docToPrint_PrintPage method.";
      System::Drawing::Font^ printFont = gcnew System::Drawing::Font( "Arial",35,FontStyle::Regular );
      e->Graphics->DrawString( text, printFont, Brushes::Black, 10, 10 );
// Declare the PrintPreviewControl object and the 
// PrintDocument object.
internal PrintPreviewControl PrintPreviewControl1;
private System.Drawing.Printing.PrintDocument docToPrint = 
    new System.Drawing.Printing.PrintDocument();
private void InitializePrintPreviewControl()
    // Construct the PrintPreviewControl.
    this.PrintPreviewControl1 = new PrintPreviewControl();
    // Set location, name, and dock style for PrintPreviewControl1.
    this.PrintPreviewControl1.Location = new Point(88, 80);
    this.PrintPreviewControl1.Name = "PrintPreviewControl1";
    this.PrintPreviewControl1.Dock = DockStyle.Fill;
    // Set the Document property to the PrintDocument 
    // for which the PrintPage event has been handled.
    this.PrintPreviewControl1.Document = docToPrint;
    // Set the zoom to 25 percent.
    this.PrintPreviewControl1.Zoom = 0.25;
    // Set the document name. This will show be displayed when 
    // the document is loading into the control.
    this.PrintPreviewControl1.Document.DocumentName = "c:\\someFile";
    // Set the UseAntiAlias property to true so fonts are smoothed
    // by the operating system.
    this.PrintPreviewControl1.UseAntiAlias = true;
    // Add the control to the form.
    this.Controls.Add(this.PrintPreviewControl1);
    // Associate the event-handling method with the
    // document's PrintPage event.
    this.docToPrint.PrintPage += 
        new System.Drawing.Printing.PrintPageEventHandler(
        docToPrint_PrintPage);
// The PrintPreviewControl will display the document
// by handling the documents PrintPage event
private void docToPrint_PrintPage(
    object sender, System.Drawing.Printing.PrintPageEventArgs e)
    // Insert code to render the page here.
    // This code will be called when the control is drawn.
    // The following code will render a simple
    // message on the document in the control.
    string text = "In docToPrint_PrintPage method.";
    System.Drawing.Font printFont = 
        new Font("Arial", 35, FontStyle.Regular);
    e.Graphics.DrawString(text, printFont,
        Brushes.Black, 10, 10);
'Declare the PrintPreviewControl object and the PrintDocument object.
Friend WithEvents PrintPreviewControl1 As PrintPreviewControl
Private WithEvents docToPrint As New Printing.PrintDocument
Private Sub InitializePrintPreviewControl()
    ' Construct the PrintPreviewControl.
    Me.PrintPreviewControl1 = New PrintPreviewControl
    ' Set location, name, and dock style for PrintPreviewControl1.
    Me.PrintPreviewControl1.Location = New Point(88, 80)
    Me.PrintPreviewControl1.Name = "PrintPreviewControl1"
    Me.PrintPreviewControl1.Dock = DockStyle.Fill
    ' Set the Document property to the PrintDocument 
    ' for which the PrintPage event has been handled.
    Me.PrintPreviewControl1.Document = docToPrint
    ' Set the zoom to 25 percent.
    Me.PrintPreviewControl1.Zoom = 0.25
    ' Set the document name. This will show be displayed when 
    ' the document is loading into the control.
    Me.PrintPreviewControl1.Document.DocumentName = "c:\someFile"
    ' Set the UseAntiAlias property to true so fonts are smoothed
    ' by the operating system.
    Me.PrintPreviewControl1.UseAntiAlias = True
    ' Add the control to the form.
    Me.Controls.Add(Me.PrintPreviewControl1)
End Sub
' The PrintPreviewControl will display the document
' by handling the documents PrintPage event
Private Sub docToPrint_PrintPage(ByVal sender As Object, _
   ByVal e As System.Drawing.Printing.PrintPageEventArgs) _
       Handles docToPrint.PrintPage
    ' Insert code to render the page here.
    ' This code will be called when the control is drawn.
    ' The following code will render a simple
    ' message on the document in the control.
    Dim text As String = "In docToPrint_PrintPage method."
    Dim printFont As New Font _
        ("Arial", 35, System.Drawing.FontStyle.Regular)
    e.Graphics.DrawString(text, printFont, _
        System.Drawing.Brushes.Black, 10, 10)
End Sub
	

Remarks

When you create an instance of the PrintPreviewControl class, some of the read/write properties are set to initial values. For a list of these values, see the PrintPreviewControl constructor.

For more information about printing with Windows Forms, see the System.Drawing.Printing namespace overview. If you wish to print from a Windows Presentation Foundation application, see the System.Printing namespace.

Gets or sets the default action description of the control for use by accessibility client applications.

(Inherited from Control)

Gets or sets a value indicating whether the control can accept data that the user drags onto it.

(Inherited from Control)

Gets or sets the edges of the container to which a control is bound and determines how a control is resized with its parent.

(Inherited from Control)

Gets the distance, in pixels, between the bottom edge of the control and the top edge of its container's client area.

(Inherited from Control)

Gets or sets the size and location of the control including its nonclient elements, in pixels, relative to the parent control.

(Inherited from Control)

Gets a value indicating whether the ImeMode property can be set to an active value, to enable IME support.

(Inherited from Control)

Gets or sets a value indicating whether the control causes validation to be performed on any controls that require validation when it receives focus.

(Inherited from Control)

Gets a value indicating whether the control, or one of its child controls, currently has the input focus.

(Inherited from Control)

Gets or sets the data context for the purpose of data binding. This is an ambient property.

(Inherited from Control)

Gets the length and height, in pixels, that is specified as the default maximum size of a control.

(Inherited from Control)

Gets the length and height, in pixels, that is specified as the default minimum size of a control.

(Inherited from Control)

Gets the DPI value for the display device where the control is currently being displayed.

(Inherited from Control)

Gets or sets which control borders are docked to its parent control and determines how a control is resized with its parent.

(Inherited from Control)

Gets or sets a value indicating whether this control should redraw its surface using a secondary buffer to reduce or prevent flicker.

(Inherited from Control)

Gets a value indicating whether the caller must call an invoke method when making method calls to the control because the caller is on a different thread than the one the control was created on.

(Inherited from Control)

Gets or sets a value indicating whether the control is visible to accessibility applications.

(Inherited from Control)

Indicates if one of the Ancestors of this control is sited and that site in DesignMode. This property is read-only.

(Inherited from Control)

Gets or sets the distance, in pixels, between the left edge of the control and the left edge of its container's client area.

(Inherited from Control)

Gets or sets the coordinates of the upper-left corner of the control relative to the upper-left corner of its container.

(Inherited from Control)

Gets the distance, in pixels, between the right edge of the control and the left edge of its container's client area.

(Inherited from Control)

Gets or sets a value indicating whether control's elements are aligned to support locales using right-to-left fonts.

(Inherited from Control)

Gets a value indicating whether the user interface is in the appropriate state to show or hide keyboard accelerators.

(Inherited from Control)

Gets or sets a value indicating whether the user can give the focus to this control using the TAB key.

(Inherited from Control)

Gets or sets the distance, in pixels, between the top edge of the control and the top edge of its container's client area.

(Inherited from Control)

Gets the parent control that is not parented by another Windows Forms control. Typically, this is the outermost Form that the control is contained in.

(Inherited from Control)

Gets or sets a value indicating whether to use the wait cursor for the current control and all child controls.

(Inherited from Control)

Gets or sets a value indicating whether the control and all its child controls are displayed.

(Inherited from Control)

Notifies the accessibility client applications of the specified AccessibleEvents for the specified child control .

(Inherited from Control)

Notifies the accessibility client applications of the specified AccessibleEvents for the specified child control.

(Inherited from Control)

Executes the specified delegate asynchronously on the thread that the control's underlying handle was created on.

(Inherited from Control)

Executes the specified delegate asynchronously with the specified arguments, on the thread that the control's underlying handle was created on.

(Inherited from Control)

Executes the specified delegate asynchronously on the thread that the control's underlying handle was created on.

(Inherited from Control)

Forces the creation of the visible control, including the creation of the handle and any visible child controls.

(Inherited from Control)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)

Releases the unmanaged resources used by the Control and its child controls and optionally releases the managed resources.

(Inherited from Control)

Retrieves the return value of the asynchronous operation represented by the IAsyncResult passed.

(Inherited from Control)

Retrieves a value indicating how a control will behave when its AutoSize property is enabled.

(Inherited from Control)

Retrieves the child control that is located at the specified coordinates, specifying whether to ignore child controls of a certain type.

(Inherited from Control) Obsolete.

Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)

Returns an object that represents a service provided by the Component or by its Container.

(Inherited from Component) Obsolete.

Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)

Invalidates a specific region of the control and causes a paint message to be sent to the control. Optionally, invalidates the child controls assigned to the control.

(Inherited from Control)

Invalidates the specified region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control. Optionally, invalidates the child controls assigned to the control.

(Inherited from Control)

Invalidates the specified region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control.

(Inherited from Control)

Invalidates the specified region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control. Optionally, invalidates the child controls assigned to the control.

(Inherited from Control)

Invalidates the specified region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control.

(Inherited from Control)

Executes the specified delegate on the thread that owns the control's underlying window handle.

(Inherited from Control)

Executes the specified delegate, on the thread that owns the control's underlying window handle, with the specified list of arguments.

(Inherited from Control)

Executes the specified delegate on the thread that owns the control's underlying window handle.

(Inherited from Control)

Executes the specified delegate on the thread that owns the control's underlying window handle.

(Inherited from Control)

Determines whether the specified key is a regular input key or a special key that requires preprocessing.

(Inherited from Control)

Transforms a size from logical to device units by scaling it for the current DPI and rounding down to the nearest integer value for width and height.

(Inherited from Control)

Raises the BackColorChanged event when the BackColor property value of the control's container changes.

(Inherited from Control)

Raises the BackgroundImageChanged event when the BackgroundImage property value of the control's container changes.

(Inherited from Control)

Raises the BindingContextChanged event when the BindingContext property value of the control's container changes.

(Inherited from Control)

Raises the EnabledChanged event when the Enabled property value of the control's container changes.

(Inherited from Control)

Raises the FontChanged event when the Font property value of the control's container changes.

(Inherited from Control)

Raises the ForeColorChanged event when the ForeColor property value of the control's container changes.

(Inherited from Control)

Raises the RightToLeftChanged event when the RightToLeft property value of the control's container changes.

(Inherited from Control)

Raises the VisibleChanged event when the Visible property value of the control's container changes.

(Inherited from Control)

Preprocesses keyboard or input messages within the message loop before they are dispatched.

(Inherited from Control)

Preprocesses keyboard or input messages within the message loop before they are dispatched.

(Inherited from Control)

Forces the control to invalidate its client area and immediately redraw itself and any child controls.

(Inherited from Control)

Causes a control bound to the BindingSource to reread all the items in the list and refresh their displayed values.

(Inherited from Control)

Resumes usual layout logic, optionally forcing an immediate layout of pending layout requests.

(Inherited from Control)

Converts the specified ContentAlignment to the appropriate ContentAlignment to support right-to-left text.

(Inherited from Control)

Converts the specified HorizontalAlignment to the appropriate HorizontalAlignment to support right-to-left text.

(Inherited from Control)

Converts the specified LeftRightAlignment to the appropriate LeftRightAlignment to support right-to-left text.

(Inherited from Control)

Converts the specified ContentAlignment to the appropriate ContentAlignment to support right-to-left text.

(Inherited from Control)

Converts the specified HorizontalAlignment to the appropriate HorizontalAlignment to support right-to-left text.

(Inherited from Control)

Converts the specified LeftRightAlignment to the appropriate LeftRightAlignment to support right-to-left text.

(Inherited from Control)

Scales a logical bitmap value to it's equivalent device unit value when a DPI change occurs.

(Inherited from Control)

Activates a child control. Optionally specifies the direction in the tab order to select the control from.

(Inherited from Control)

Returns a String containing the name of the Component, if any. This method should not be overridden.

(Inherited from Component)

Occurs when the DPI setting for a control is changed programmatically after the DPI of its parent control or form has changed.

(Inherited from Control)

Occurs when the DPI setting for a control is changed programmatically before a DPI change event for its parent control or form has occurred.

(Inherited from Control)

Occurs during a drag-and-drop operation and enables the drag source to determine whether the drag-and-drop operation should be canceled.

(Inherited from Control)