PaperSize.PaperName Właściwość

Definicja

Pobiera lub ustawia nazwę typu papieru.

public:
 property System::String ^ PaperName { System::String ^ get(); void set(System::String ^ value); };
public string PaperName { get; set; }
member this.PaperName : string with get, set
Public Property PaperName As String

Wartość właściwości

Nazwa typu papieru.

Wyjątki

Właściwość nie jest ustawiona Kind na Custom.

Przykłady

Poniższy przykład kodu wypełnia comboPaperSize pole kombi obsługiwanymi rozmiarami papieru drukarki. Element PaperName jest identyfikowany jako właściwość, która zapewni ciąg wyświetlania elementu dodawanego za pośrednictwem DisplayMember właściwości pola kombi. W przykładzie założono, że PrintDocument istnieje zmienna o nazwie printDoc i że istnieje określone pole kombi.

// Add list of supported paper sizes found on the printer.
// The DisplayMember property is used to identify the property that will provide the display String*.
comboPaperSize->DisplayMember = "PaperName";
PaperSize^ pkSize;
for ( int i = 0; i < printDoc->PrinterSettings->PaperSizes->Count; i++ )
{
   pkSize = printDoc->PrinterSettings->PaperSizes[ i ];
   comboPaperSize->Items->Add( pkSize );
}

// Create a PaperSize and specify the custom paper size through the constructor and add to combobox.
PaperSize^ pkCustomSize1 = gcnew PaperSize( "First custom size",100,200 );
comboPaperSize->Items->Add( pkCustomSize1 );
// Add list of supported paper sizes found on the printer. 
// The DisplayMember property is used to identify the property that will provide the display string.
comboPaperSize.DisplayMember = "PaperName";

PaperSize pkSize;
for (int i = 0; i < printDoc.PrinterSettings.PaperSizes.Count; i++){
    pkSize = printDoc.PrinterSettings.PaperSizes[i];
    comboPaperSize.Items.Add(pkSize);
}

// Create a PaperSize and specify the custom paper size through the constructor and add to combobox.
PaperSize pkCustomSize1 = new PaperSize("First custom size", 100, 200);

comboPaperSize.Items.Add(pkCustomSize1);
' Add list of supported paper sizes found on the printer. 
' The DisplayMember property is used to identify the property that will provide the display string.
comboPaperSize.DisplayMember = "PaperName"

Dim pkSize As PaperSize
For i = 0 to printDoc.PrinterSettings.PaperSizes.Count - 1
    pkSize = printDoc.PrinterSettings.PaperSizes.Item(i)
    comboPaperSize.Items.Add(pkSize)
Next

' Create a PaperSize and specify the custom paper size through the constructor and add to combobox.
Dim pkCustomSize1 As New PaperSize("Custom Paper Size", 100, 200)

comboPaperSize.Items.Add(pkCustomSize1)

Uwagi

Nazwę papieru można ustawić tylko wtedy, gdy właściwość jest ustawiona Kind na Custom.

Dotyczy

Zobacz też