I need to print a treeview

beerbsh316

Member
Joined
Jan 10, 2007
Messages
10
Programming Experience
5-10
I am trying to print out a treeview in my application. I have been able to draw the treeview to a bitmap but after that I am not sure what I need to do so I can send it to the printer. Any help would be appreciated.
 
Ok I used the code from that other topic but I am having a problem. The way I am setting this up is that on the main screen of my app the user clicks a print button this opens a new form that only has the treeview on it. I am doing that to try and hopefully fit everything on the treeview on one screen as opposed to my smaller one on the main screen that has scrollbars. Now I put the code into the form load event of the form that opens when the user clicks print however it looked like it was just taking a screenshot at that particular instance and not a bitmap of just the treeview like I am hoping for. Also note that I did change the line
bmp=getsnap(panel1)
to
bmp=getsnap(treeview1)

What am I doing wrong
 
Form Load event happens before form is shown, it isn't shown until after the Load is fully finished. Use the Form Shown event instead. In addition you need to give the form paint a little helping hand to finish drawing before taking the snapshot, to do this call Application.DoEvents() before the 'getsnap' call. I have tested this and it does work. You can specify any single control or container control as input parameter to the getsnap function method, so getsnap(treeview1) is fine.
 
Back
Top