question

WONGTony-4228 avatar image
0 Votes"
WONGTony-4228 asked XingyuZhao-MSFT commented

VB.net print simple table form

i am new to VB.net. I have experience on asp.net(VB)

i wish to print a simple table at VB form by clicking a button

i find someone make use of Excel to print but i do not wish to install Office excel.

is it possible to make use of VB.net alone without additional software / plugin?

Thanks.

dotnet-visual-basic
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @WONGTony-4228 ,
According to your description, I have a question to confirm with you.
What's the type of you application? winform? web form?
Please provide more details and it will help us make a test.
We are waiting for your update.

0 Votes 0 ·

winform

the table form is simple structure

Should i use "printdocument"?

0 Votes 0 ·

Hi @WONGTony-4228 ,
Thanks for your feedback.

Should i use "printdocument"?

Yes. You can consider binding your table to DataGridView and then refer to the following example to print it.

Printing of DataGridView

The code in the reference is C# and you can convert it to vb. net.
Besides, if you need further assistance, please let me know.

0 Votes 0 ·

it seems PrintDocument is too simple

My format is a simple INVOICE with some merged fields

Can i create a html file and print directly from vb.net? Thanks.

0 Votes 0 ·

Hi @WONGTony-4228
May I know if you have got any chance to check my reply? Please feel free to share more detailed information to us.

0 Votes 0 ·

1 Answer

XingyuZhao-MSFT avatar image
0 Votes"
XingyuZhao-MSFT answered XingyuZhao-MSFT edited

Hi @WONGTony-4228 ,
To print a html file, you can use WebBrowser control.
For example:

     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
         WebBrowser1.DocumentText = System.IO.File.ReadAllText("your html file path")
     End Sub   
     Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
         WebBrowser1.Print()
     End Sub

Hope it could be helpful.

Best Regards,
Xingyu Zhao


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.