2010-05-06 57 views

回答

0

下面的例子是使用/繼承PrintDocument類的基本思想:

using System.Drawing.Printing; 

public class PrintDoc : PrintDocument 
{ 
    // there are other properties you can enter here 
    // for instance, page orientation, size, font, etc. 

    private string textout; 

    public string PrintText 
    { 
     get { return textout; } 
     set { textout = value; } 
    } 

    // you will also need to add any appropriate class ctor 
    // experiment with the PrintDocument class to learn more 
} 
從窗體的按鈕事件

然後,調用是這樣的:

public void PrintDocument() 
{ 
     //instance PrintDocument class 
     PrintDoc printer = new PrintDoc(); 

     //set PrintText 
     printer.PrintText = myTextBox.Text; 

     printer.Print(); // very straightforward 
} 
+0

非常感謝你的回覆。 – SRIKANTH 2010-05-06 12:32:13

相關問題