PageSetupDialog Klasa
Definicja
Umożliwia użytkownikom zmianę ustawień drukowania związanych ze stronami, w tym marginesów i orientacji papieru.Enables users to change page-related print settings, including margins and paper orientation. Klasa ta nie może być dziedziczona.This class cannot be inherited.
public ref class PageSetupDialog sealed : System::Windows::Forms::CommonDialog
public sealed class PageSetupDialog : System.Windows.Forms.CommonDialog
type PageSetupDialog = class
inherit CommonDialog
Public NotInheritable Class PageSetupDialog
Inherits CommonDialog
- Dziedziczenie
Przykłady
Poniższy przykład kodu demonstruje PageSetupDialog użycie PageSettings , PrinterSettings , i ShowNetwork właściwości.The following code example demonstrates the PageSetupDialog using the PageSettings, PrinterSettings, and ShowNetwork properties. Aby uruchomić ten przykład, należy umieścić go w postaci zawierającej Button nazwane Button1
, ListBox nazwane ListBox1
i PageSetupDialog nazwanych PageSetupDialog1
.To run this example, place it in a form containing a Button named Button1
, a ListBox named ListBox1
, and a PageSetupDialog named PageSetupDialog1
. Upewnij się, że zdarzenie kliknięcia przycisku jest połączone z metodą obsługi zdarzeń w tym przykładzie.Ensure the button's click event is connected to the event-handling method in this example.
//This method displays a PageSetupDialog object. If the
// user clicks OK in the dialog, selected results of
// the dialog are displayed in ListBox1.
void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
// Initialize the dialog's PrinterSettings property to hold user
// defined printer settings.
PageSetupDialog1->PageSettings = gcnew System::Drawing::Printing::PageSettings;
// Initialize dialog's PrinterSettings property to hold user
// set printer settings.
PageSetupDialog1->PrinterSettings = gcnew System::Drawing::Printing::PrinterSettings;
//Do not show the network in the printer dialog.
PageSetupDialog1->ShowNetwork = false;
//Show the dialog storing the result.
System::Windows::Forms::DialogResult result = PageSetupDialog1->ShowDialog();
// If the result is OK, display selected settings in
// ListBox1. These values can be used when printing the
// document.
if ( result == ::DialogResult::OK )
{
array<Object^>^results = {PageSetupDialog1->PageSettings->Margins,PageSetupDialog1->PageSettings->PaperSize,PageSetupDialog1->PageSettings->Landscape,PageSetupDialog1->PrinterSettings->PrinterName,PageSetupDialog1->PrinterSettings->PrintRange};
ListBox1->Items->AddRange( results );
}
}
//This method displays a PageSetupDialog object. If the
// user clicks OK in the dialog, selected results of
// the dialog are displayed in ListBox1.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
// Initialize the dialog's PrinterSettings property to hold user
// defined printer settings.
PageSetupDialog1.PageSettings =
new System.Drawing.Printing.PageSettings();
// Initialize dialog's PrinterSettings property to hold user
// set printer settings.
PageSetupDialog1.PrinterSettings =
new System.Drawing.Printing.PrinterSettings();
//Do not show the network in the printer dialog.
PageSetupDialog1.ShowNetwork = false;
//Show the dialog storing the result.
DialogResult result = PageSetupDialog1.ShowDialog();
// If the result is OK, display selected settings in
// ListBox1. These values can be used when printing the
// document.
if (result == DialogResult.OK)
{
object[] results = new object[]{
PageSetupDialog1.PageSettings.Margins,
PageSetupDialog1.PageSettings.PaperSize,
PageSetupDialog1.PageSettings.Landscape,
PageSetupDialog1.PrinterSettings.PrinterName,
PageSetupDialog1.PrinterSettings.PrintRange};
ListBox1.Items.AddRange(results);
}
}
'This method displays a PageSetupDialog object. If the
' user clicks OK in the dialog, selected results of
' the dialog are displayed in ListBox1.
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
' Initialize the dialog's PrinterSettings property to hold user
' defined printer settings.
PageSetupDialog1.PageSettings = _
New System.Drawing.Printing.PageSettings
' Initialize dialog's PrinterSettings property to hold user
' set printer settings.
PageSetupDialog1.PrinterSettings = _
New System.Drawing.Printing.PrinterSettings
'Do not show the network in the printer dialog.
PageSetupDialog1.ShowNetwork = False
'Show the dialog storing the result.
Dim result As DialogResult = PageSetupDialog1.ShowDialog()
' If the result is OK, display selected settings in
' ListBox1. These values can be used when printing the
' document.
If (result = DialogResult.OK) Then
Dim results() As Object = New Object() _
{PageSetupDialog1.PageSettings.Margins, _
PageSetupDialog1.PageSettings.PaperSize, _
PageSetupDialog1.PageSettings.Landscape, _
PageSetupDialog1.PrinterSettings.PrinterName, _
PageSetupDialog1.PrinterSettings.PrintRange}
ListBox1.Items.AddRange(results)
End If
End Sub
Uwagi
Okno PageSetupDialog dialogowe modyfikuje PageSettings i PrinterSettings Informacje dla danego elementu Document .The PageSetupDialog dialog box modifies the PageSettings and PrinterSettings information for a given Document. Użytkownik może włączyć sekcje okna dialogowego, aby manipulować drukowaniem i marginesami. Orientacja papieru, rozmiar i Źródło; i wyświetlić przyciski pomocy i sieci.The user can enable sections of the dialog box to manipulate printing and margins; paper orientation, size, and source; and to show Help and network buttons. MinMarginsWłaściwość definiuje minimalne marginesy, które użytkownik może wybrać.The MinMargins property defines the minimum margins a user can select.
Podczas tworzenia wystąpienia PageSetupDialog klasy właściwości do odczytu/zapisu są ustawiane na wartości początkowe.When you create an instance of the PageSetupDialog class, the read/write properties are set to initial values. Aby uzyskać listę tych wartości, zobacz PageSetupDialog Konstruktor.For a list of these values, see the PageSetupDialog constructor.
Ze względu na to, że PageSetupDialog Ustawienia strony wymagają wyświetlania, należy Document ustawić PrinterSettings Właściwość,, lub PageSettings przed wywołaniem ShowDialog ; w przeciwnym razie wystąpi wyjątek.Because a PageSetupDialog needs page settings to display, you need to set the Document, PrinterSettings, or PageSettings property before calling ShowDialog; otherwise, an exception will occur.
Konstruktory
PageSetupDialog() |
Inicjuje nowe wystąpienie klasy PageSetupDialog.Initializes a new instance of the PageSetupDialog class. |
Właściwości
AllowMargins |
Pobiera lub ustawia wartość wskazującą, czy sekcja marginesów okna dialogowego jest włączona.Gets or sets a value indicating whether the margins section of the dialog box is enabled. |
AllowOrientation |
Pobiera lub ustawia wartość wskazującą, czy sekcja Orientacja okna dialogowego (pozioma i pionowa) jest włączona.Gets or sets a value indicating whether the orientation section of the dialog box (landscape versus portrait) is enabled. |
AllowPaper |
Pobiera lub ustawia wartość wskazującą, czy sekcja papieru okna dialogowego (rozmiar papieru i źródło papieru) jest włączona.Gets or sets a value indicating whether the paper section of the dialog box (paper size and paper source) is enabled. |
AllowPrinter |
Pobiera lub ustawia wartość wskazującą, czy przycisk drukarki jest włączony.Gets or sets a value indicating whether the Printer button is enabled. |
CanRaiseEvents |
Pobiera wartość wskazującą, czy składnik może zgłosić zdarzenie.Gets a value indicating whether the component can raise an event. (Odziedziczone po Component) |
Container |
Pobiera IContainer , który zawiera Component .Gets the IContainer that contains the Component. (Odziedziczone po Component) |
DesignMode |
Pobiera wartość wskazującą, czy Component jest aktualnie w trybie projektowania.Gets a value that indicates whether the Component is currently in design mode. (Odziedziczone po Component) |
Document |
Pobiera lub ustawia wartość wskazującą, że PrintDocument mają zostać pobrane ustawienia strony.Gets or sets a value indicating the PrintDocument to get page settings from. |
EnableMetric |
Pobiera lub ustawia wartość wskazującą, czy ustawienia marginesu, gdy są wyświetlane w milimetrach, powinny być automatycznie konwertowane na i od setnych cala.Gets or sets a value indicating whether the margin settings, when displayed in millimeters, should be automatically converted to and from hundredths of an inch. |
Events |
Pobiera listę programów obsługi zdarzeń, które są dołączone do tego elementu Component .Gets the list of event handlers that are attached to this Component. (Odziedziczone po Component) |
MinMargins |
Pobiera lub ustawia wartość wskazującą minimalne marginesy (w setkach cala), który użytkownik może wybrać.Gets or sets a value indicating the minimum margins, in hundredths of an inch, the user is allowed to select. |
PageSettings |
Pobiera lub ustawia wartość wskazującą ustawienia strony do zmodyfikowania.Gets or sets a value indicating the page settings to modify. |
PrinterSettings |
Pobiera lub ustawia ustawienia drukarki, które są modyfikowane, gdy użytkownik kliknie przycisk drukarki w oknie dialogowym.Gets or sets the printer settings that are modified when the user clicks the Printer button in the dialog. |
ShowHelp |
Pobiera lub ustawia wartość wskazującą, czy przycisk pomocy jest widoczny.Gets or sets a value indicating whether the Help button is visible. |
ShowNetwork |
Pobiera lub ustawia wartość wskazującą, czy przycisk sieci jest widoczny.Gets or sets a value indicating whether the Network button is visible. |
Site |
Pobiera lub ustawia wartość ISite Component .Gets or sets the ISite of the Component. (Odziedziczone po Component) |
Tag |
Pobiera lub ustawia obiekt, który zawiera dane dotyczące formantu.Gets or sets an object that contains data about the control. (Odziedziczone po CommonDialog) |
Metody
CreateObjRef(Type) |
Tworzy obiekt, który zawiera wszystkie istotne informacje wymagane do wygenerowania serwera proxy używanego do komunikacji z obiektem zdalnym.Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Odziedziczone po MarshalByRefObject) |
Dispose() |
Zwalnia wszelkie zasoby używane przez element Component.Releases all resources used by the Component. (Odziedziczone po Component) |
Dispose(Boolean) |
Zwalnia zasoby niezarządzane używane przez element Component i opcjonalnie zwalnia zasoby zarządzane.Releases the unmanaged resources used by the Component and optionally releases the managed resources. (Odziedziczone po Component) |
Equals(Object) |
Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.Determines whether the specified object is equal to the current object. (Odziedziczone po Object) |
GetHashCode() |
Służy jako domyślna funkcja skrótu.Serves as the default hash function. (Odziedziczone po Object) |
GetLifetimeService() |
Nieaktualne.
Pobiera bieżący obiekt usługi okresu istnienia, który kontroluje zasady okresu istnienia dla tego wystąpienia.Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Odziedziczone po MarshalByRefObject) |
GetService(Type) |
Zwraca obiekt, który reprezentuje usługę dostarczoną przez Component lub przez Container .Returns an object that represents a service provided by the Component or by its Container. (Odziedziczone po Component) |
GetType() |
Pobiera Type bieżące wystąpienie.Gets the Type of the current instance. (Odziedziczone po Object) |
HookProc(IntPtr, Int32, IntPtr, IntPtr) |
Definiuje wspólną procedurę haka okna dialogowego, która została zastąpiona w celu dodania określonych funkcji do wspólnego okna dialogowego.Defines the common dialog box hook procedure that is overridden to add specific functionality to a common dialog box. (Odziedziczone po CommonDialog) |
InitializeLifetimeService() |
Nieaktualne.
Uzyskuje obiekt usługi istnienia w celu kontrolowania zasad okresu istnienia dla tego wystąpienia.Obtains a lifetime service object to control the lifetime policy for this instance. (Odziedziczone po MarshalByRefObject) |
MemberwiseClone() |
Tworzy skróconą kopię bieżącego elementu Object .Creates a shallow copy of the current Object. (Odziedziczone po Object) |
MemberwiseClone(Boolean) |
Tworzy skróconą kopię bieżącego MarshalByRefObject obiektu.Creates a shallow copy of the current MarshalByRefObject object. (Odziedziczone po MarshalByRefObject) |
OnHelpRequest(EventArgs) |
Podnosi HelpRequest zdarzenie.Raises the HelpRequest event. (Odziedziczone po CommonDialog) |
OwnerWndProc(IntPtr, Int32, IntPtr, IntPtr) |
Definiuje procedurę okna właściciela, która została zastąpiona w celu dodania określonych funkcji do wspólnego okna dialogowego.Defines the owner window procedure that is overridden to add specific functionality to a common dialog box. (Odziedziczone po CommonDialog) |
Reset() |
Resetuje wszystkie opcje do wartości domyślnych.Resets all options to their default values. |
RunDialog(IntPtr) |
Gdy jest zastępowany w klasie pochodnej, określa wspólne okno dialogowe.When overridden in a derived class, specifies a common dialog box. (Odziedziczone po CommonDialog) |
ShowDialog() |
Uruchamia wspólne okno dialogowe z domyślnym właścicielem.Runs a common dialog box with a default owner. (Odziedziczone po CommonDialog) |
ShowDialog(IWin32Window) |
Uruchamia wspólne okno dialogowe z określonym właścicielem.Runs a common dialog box with the specified owner. (Odziedziczone po CommonDialog) |
ToString() |
Zwraca wartość String zawierającą nazwę Component (jeśli istnieje).Returns a String containing the name of the Component, if any. Ta metoda nie powinna być przesłaniana.This method should not be overridden. (Odziedziczone po Component) |
Zdarzenia
Disposed |
Występuje, gdy składnik zostanie usunięty przez wywołanie Dispose() metody.Occurs when the component is disposed by a call to the Dispose() method. (Odziedziczone po Component) |
HelpRequest |
Występuje, gdy użytkownik kliknie przycisk Pomoc w wspólnym oknie dialogowym.Occurs when the user clicks the Help button on a common dialog box. (Odziedziczone po CommonDialog) |