Need help in printing a dynamic form

hawkseye

Active member
Joined
Dec 4, 2004
Messages
28
Programming Experience
Beginner
hello

i have a form on which different things (labels, graph, etc) are drawn on runtime based on the values in the database. Now the problem is i want to get the print preview and then print this form but i dont know how. I read somewhere that whe have to draw everything in Form_PrintPage(......) method to do this.
isnt there any easier way cause ill have to run every query again to do this :(
can i create an image of this form and later print n print preview that image


plz help me.
thanks
 
Last edited:

hawkseye

Active member
Joined
Dec 4, 2004
Messages
28
Programming Experience
Beginner
i am using printDocument but it simply shows me an empty page in printpreview.

im attachin a file plz check it
 

Attachments

  • report.txt
    58.5 KB · Views: 209

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
To print the entire form as is simply add the provied module to the project, then in the form you want printed simply use:
VB.NET:
Call PrintForm(Me)

basically it'll take a screenshot of the form and print it like a bitmap
 
Last edited:

hawkseye

Active member
Joined
Dec 4, 2004
Messages
28
Programming Experience
Beginner
That was some code :) . WEll it works but prints only the part of form which is visible on the screen but the rest of the form which is below or above is just ignored.
 

ncamoens

Member
Joined
Mar 18, 2006
Messages
7
Programming Experience
Beginner
hi does that provided module need any references or import statements?
because when i added it, i got 12 build errors, with things like 'picturebox not declared' and 'theform not declared' and 'messagebox not declared'.
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
it does, but the references are already imported by default in the IDE, unless of course someone's removed them in which case you can add them back or put in these lines:
VB.NET:
Imports System
Imports System.Windows.Forms

also when i get the chance i'm going to fix up that module and try to solve some of the problems it has as well
 

americamysweethome

New member
Joined
Jun 18, 2007
Messages
1
Programming Experience
Beginner
Hi,

I use your FormUntilities.vb and call print the form by including this line of code 'Call PrintForm(Me)' in my aspx form, but it gives me this error: c:\inetpub\wwwroot\Proj1\Form1.aspx.vb(601): Value of type 'Proj.dispForm' cannot be converted to 'System.Windows.Forms.Form'.


Please advise what I should do to solve this problem.
 
Top Bottom