0
當我在這些文本框中輸入文本時,通過單擊打印按鈕,它應該直接使用連接的打印機打印。任何人都可以幫助我,我應該怎麼做?C#.net windows應用程序 - 打印文本框值
當我在這些文本框中輸入文本時,通過單擊打印按鈕,它應該直接使用連接的打印機打印。任何人都可以幫助我,我應該怎麼做?C#.net windows應用程序 - 打印文本框值
下面的例子是使用/繼承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
}
非常感謝你的回覆。 – SRIKANTH 2010-05-06 12:32:13