开发者

C# .net windows application - Printing Text Box Values

I have two text boxes when i input in these text boxes , by clicking the print button , it should directly printed with the 开发者_C百科connected printer. can anybody help me how should i do this?


The example below is a basic idea of using/inheriting the PrintDocument class:

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
}

Then from your form's button event, call something like:

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

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

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜