שתף באמצעות


How do you create a print button using visual basic?

Question

Wednesday, December 9, 2009 3:59 PM

I want to be able to have a print button on my form that when clicked, automatically prompts the users printer to print the form in it's current state when the button was pressed. Please supply an example of the code required or an explanation of how to write it properly.

Thanks for your help :)

All replies (6)

Wednesday, December 9, 2009 4:03 PM ✅Answered

download the Visual Basic PowerPacks

has a component called PrintForm

in the button click event just need this:

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

Wednesday, December 9, 2009 4:11 PM

I want to be able to have a print button on my form that when clicked, automatically prompts the users printer to print the form in it's current state when the button was pressed. Please supply an example of the code required or an explanation of how to write it properly.

Thanks for your help :)

Jwavila is right, so here is the address for you to download: http://msdn.microsoft.com/en-us/vbasic/bb735936.aspx Don't judge me, just Upgrade me. Thanks!


Wednesday, December 9, 2009 4:44 PM

For VB2008, PowerPacks is included.  Don't download anything.


Wednesday, December 9, 2009 8:26 PM

I have VB 2008 Express Edition. But I can't find 'Power Pack' or the 'PrintForm' ? Unless it isn't called print form? is it called something else similar like: print dialogue, print document, print preview control, print preview dialogue?


Wednesday, December 9, 2009 8:33 PM

It should be on the .NET Framework Components tab between "PrintDocument" and "PrintPreviewControl".


Monday, February 14, 2011 1:12 PM

hi. i have a vb.net program and i use a print button, i use a database "msaccess" it is connected to my vb.net program. now my problem is i want to print the database in msaccess using the printbutton. it is view in datagridview. anyone can help me... badly need your help guys.