Hi

I have been trying for a while to get a toolbar to work with a print function and cannot get it to work. However does anybody know if you can just use a normal button to print the form it is on? If so how??
I have already tried [/Me.Print()] but this does not seem to work.

Recommended Answers

All 12 Replies

hey Baker,
Yes there is a way to print the form that you have entered data in,
Please visit:
http://msdn2.microsoft.com/en-us/vbasic/bb735936.aspx
this website got download link plz install the power pack and then make sure your toolbar got power pack tools,
from there you will be able to select the print form and drag it to form which you wanna print,
once you will install that power pack then you will go to Start>programs>Powerpack and select the example form and open that form and from there you can see the coding and setting for Print form. If you have anyother query then let us know. thanks and if it helps you then you can click on solved.

hey Baker,
Yes there is a way to print the form that you have entered data in,
Please visit:
http://msdn2.microsoft.com/en-us/vbasic/bb735936.aspx
this website got download link plz install the power pack and then make sure your toolbar got power pack tools,
from there you will be able to select the print form and drag it to form which you wanna print,
once you will install that power pack then you will go to Start>programs>Powerpack and select the example form and open that form and from there you can see the coding and setting for Print form. If you have anyother query then let us know. thanks and if it helps you then you can click on solved.

Hi Alekhan
Thanks for your reply. I have downloaded the powerpack. The problem I now have is it says [/PrintBoatDefectsAndWhoOwnsThem] is not delcared. That is the name of the form. However I cannot see where they have declared it. Below shows my code. What possible way can i delcare it?
[/Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button1.Visible = False
PrintBoatDefectsAndOwnsThem.PrintAction = Printing.PrintAction.PrintToPreview
PrintBoatDefectsAndOwnsThem.Print()
Button1.Visible = True

End Sub]
Thanks

ok no problem, follow the following steps.
1. Open Visual studio you have, Then select a new project.
2. Once project is opened the default form 1 will be there
3. drag 3 labels, 3 textboxes 1 button.
4. change Label Text: Label 1 as FirstName, Label2 as LastName, Label3 as Gender:
5. Leave the Text boxes text to empty.
6. Give Button text as Show.
7. Now from toolbar, see Power Pack and Drag the PrintForm tool to your form.
8. and now double click you button and write the following code

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Hide the print button
Button1.Visible = False
' Set the PrintAction to display a Print Preview dialog
Form1.PrintAction = Printing.PrintAction.PrintToPreview
' Print a copy of the form
Form1.Print()
' Restore the print button
Button1.Visible = True
End Sub


and that is all now if you will change name of your form it will automatically change here in code. isnt it too easy? anyway if you still feel any problem let me know.
Thanks..

ok no problem, follow the following steps.
1. Open Visual studio you have, Then select a new project.
2. Once project is opened the default form 1 will be there
3. drag 3 labels, 3 textboxes 1 button.
4. change Label Text: Label 1 as FirstName, Label2 as LastName, Label3 as Gender:
5. Leave the Text boxes text to empty.
6. Give Button text as Show.
7. Now from toolbar, see Power Pack and Drag the PrintForm tool to your form.
8. and now double click you button and write the following code

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Hide the print button
Button1.Visible = False
' Set the PrintAction to display a Print Preview dialog
Form1.PrintAction = Printing.PrintAction.PrintToPreview
' Print a copy of the form
Form1.Print()
' Restore the print button
Button1.Visible = True
End Sub


and that is all now if you will change name of your form it will automatically change here in code. isnt it too easy? anyway if you still feel any problem let me know.
Thanks..

For some reason I cannot drag the print form tool. I have also tried copying and pasting it but it does not work. I also cannot see it in the toolbox..
thanks

No problem buddy,

I am sending an attached file (zipped) you extract the file and open in your project and then see if there is any error, if you will still have problem just capture screen for error window. ok
take care

No problem buddy,

I am sending an attached file (zipped) you extract the file and open in your project and then see if there is any error, if you will still have problem just capture screen for error window. ok
take care

Sorry to bother you again but I cannot open the file it says it is invalid or corrupted.

yes have you unzipped the file??

Hi sorry I didn't
I have it working now:)
Thanks you have been a great help
All the best

you are welcome,

I may soon starting Tutorial on VB.Net You may join them to learn more.

Take Care
Happy Programming.

in Visual Studio 2008 their is a built in ocx with the name of Print form available you can easily print the form using this control.

in Visual Studio 2008 their is built in ocx control available with the name of Print Form you can easily do this task using this control.

thanx for your help microdeveloper.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.