Share print document vb.net,

phamvuwalrus

New member
#vb.net, #Print, #Document, #Programming ** Cách in tài liệu trong VB.NET **

In một tài liệu trong VB.NET là một nhiệm vụ tương đối đơn giản.Các bước sau đây sẽ chỉ cho bạn cách thực hiện:

1. ** Nhập hệ thống.Drawing.printing không gian tên. ** Không gian tên này chứa các lớp mà bạn cần sử dụng để in một tài liệu.
2. ** Tạo một đối tượng printDocument. ** Đối tượng này đại diện cho tài liệu mà bạn muốn in.
3. ** Thêm trình xử lý sự kiện PrintPage vào đối tượng printDocument. ** Trình xử lý sự kiện này sẽ được gọi khi tài liệu được in.
4. Trong trình xử lý sự kiện PrintPage, bạn có thể sử dụng đối tượng đồ họa để vẽ tài liệu trên máy in.
5. ** Gọi phương thức in của đối tượng printDocument. ** Điều này sẽ bắt đầu quá trình in.

Dưới đây là một ví dụ về cách in một tài liệu trong vb.net:

`` `VBNet
Nhập hệ thống.Drawing.printing

Lớp công khai Mẫu1

Công cộng Sub PrintDocument (Người gửi Byval là đối tượng, ByVal E là System.Drawing.printing.PrinteVentArss) Xử lý printdocument.printpage
'Nhận đối tượng đồ họa cho máy in.
Dim g như đồ họa = ví dụ

'Vẽ tài liệu trên máy in.
G.DrawString ("Hello World!", Phông chữ mới ("Arial", 24), Brush.Black, 100, 100)
Kết thúc phụ

Kết thúc lớp học
`` `

Để biết thêm thông tin về in trong vb.net, vui lòng xem các tài nguyên sau:

* [MSDN: in] (PrintDocument Class (System.Drawing.Printing))
* [Stack Overflow: In in vb.net] (Newest 'vb.net+printing' Questions)
* [Hướng dẫn: In trong vb.net] (https://www.tutorialspoint.com/vbnet/vbnet_printing.htm)
=======================================
#vb.net, #Print, #Document, #Programming **How to Print a Document in VB.NET**

Printing a document in VB.NET is a relatively simple task. The following steps will show you how to do it:

1. **Import the System.Drawing.Printing namespace.** This namespace contains the classes that you need to use to print a document.
2. **Create a PrintDocument object.** This object represents the document that you want to print.
3. **Add a PrintPage event handler to the PrintDocument object.** This event handler will be called when the document is being printed.
4. In the PrintPage event handler, you can use the Graphics object to draw the document on the printer.
5. **Call the Print method of the PrintDocument object.** This will start the printing process.

Here is an example of how to print a document in VB.NET:

```vbnet
Imports System.Drawing.Printing

Public Class Form1

Public Sub PrintDocument(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles PrintDocument.PrintPage
' Get the Graphics object for the printer.
Dim g As Graphics = e.Graphics

' Draw the document on the printer.
g.DrawString("Hello World!", New Font("Arial", 24), Brushes.Black, 100, 100)
End Sub

End Class
```

For more information on printing in VB.NET, please see the following resources:

* [MSDN: Printing](https://docs.microsoft.com/en-us/dotnet/api/system.drawing.printing.printdocument)
* [Stack Overflow: Printing in VB.NET](https://stackoverflow.com/questions/tagged/vb.net+printing)
* [TutorialsPoint: Printing in VB.NET](https://www.tutorialspoint.com/vbnet/vbnet_printing.htm)
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top