日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

计算机打印机用户,如何:在 Windows 窗体中选择连接到用户计算机的打印机

發布時間:2024/10/8 windows 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 计算机打印机用户,如何:在 Windows 窗体中选择连接到用户计算机的打印机 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

使用 PrintDialog 組件選擇要使用的打印機。

在下面的代碼示例中,有兩個要處理的事件。第一個事件是 Button 控件的 Click 事件,在該事件中,PrintDialog 類被實例化,并且用戶選擇的打印機在 DialogResult 屬性中捕獲。

第二個事件是 PrintDocument**** 組件的 PrintPage 事件,在該事件中,將一個示例文檔打印到指定的打印機。

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim PrintDialog1 As New PrintDialog()

PrintDialog1.Document = PrintDocument1

Dim result As DialogResult = PrintDialog1.ShowDialog()

If (result = DialogResult.OK) Then

PrintDocument1.Print()

End If

End Sub

Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

e.Graphics.FillRectangle(Brushes.Red, New Rectangle(500, 500, 500, 500))

End Sub

private void button1_Click(object sender, System.EventArgs e)

{

PrintDialog printDialog1 = new PrintDialog();

printDialog1.Document = printDocument1;

DialogResult result = printDialog1.ShowDialog();

if (result == DialogResult.OK)

{

printDocument1.Print();

}

}

private void printDocument1_PrintPage(object sender,

System.Drawing.Printing.PrintPageEventArgs e)

{

e.Graphics.FillRectangle(Brushes.Red,

new Rectangle(500, 500, 500, 500));

}

private void button1_Click(Object sender, System.EventArgs e)

{

PrintDialog printDialog1 = new PrintDialog();

printDialog1.set_Document(printDocument1);

DialogResult result = printDialog1.ShowDialog();

if (result == DialogResult.OK)

{

printDocument1.Print();

}

}

private void printDocument1_PrintPage(Object sender,

System.Drawing.Printing.PrintPageEventArgs e)

{

e.get_Graphics().FillRectangle(Brushes.get_Red(),

new Rectangle(500, 500, 500, 500));

}

private:

void button1_Click(System::Object ^ sender,

System::EventArgs ^ e)

{

PrintDialog ^ printDialog1 = gcnew PrintDialog();

printDialog1->Document = printDocument1;

System::Windows::Forms::DialogResult result =

printDialog1->ShowDialog();

if (result == DialogResult::OK)

{

printDocument1->Print();

}

}

private:

void printDocument1_PrintPage(System::Object ^ sender,

System::Drawing::Printing::PrintPageEventArgs ^ e)

{

e->Graphics->FillRectangle(Brushes::Red,

Rectangle(500, 500, 500, 500));

}

((Visual C#、Visual J# 和 Visual C++)在窗體的構造函數中放入以下代碼以注冊事件處理程序。

this.printDocument1.PrintPage += new

System.Drawing.Printing.PrintPageEventHandler

(this.printDocument1_PrintPage);

this.button1.Click += new System.EventHandler(this.button1_Click);

this.printDocument1.add_PrintPage(new

System.Drawing.Printing.PrintPageEventHandler

(this.printDocument1_PrintPage));

this.button1.add_Click(new System.EventHandler(this.button1_Click));

this->printDocument1->PrintPage += gcnew

System::Drawing::Printing::PrintPageEventHandler

(this, &Form1::printDocument1_PrintPage);

this->button1->Click += gcnew

System::EventHandler(this, &Form1::button1_Click);

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的计算机打印机用户,如何:在 Windows 窗体中选择连接到用户计算机的打印机的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。