Click here to Skip to main content
15,878,543 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to print window form contents or form in vb.net?
Posted
Updated 13-Jan-12 17:46pm
v2
Comments
Sergey Alexandrovich Kryukov 13-Jan-12 23:54pm    
What is "form in vb.net"? Please see my comments below.
--SA
Sergey Alexandrovich Kryukov 13-Jan-12 23:58pm    

A suggestion to all experts:

We should stop attempting to answer any questions if OP does not properly specify type of application, UI library and other relevant detail which would exclude this kind of confusion. All type mentioned in the question should be written in fully-qualified form. We should request it and only answer when OP comply. Multiple failures to specify such detail became a curse of this forum.



Please see my comments to the answer by Palraj001 below.

I did not delete this question only to bring this problem and my suggestion to your attention.
--SA

1 solution

Hi,

try this..

Place your page inside the DIV.


JavaScript
<script type="text/javascript">
<!--
function printchart(elementId)
{
 var printContent = document.getElementById(elementId);
 var windowUrl = 'about:blank';
 var uniqueName = new Date();
 var windowName = 'Print' + uniqueName.getTime();
 var printWindow = window.open(windowUrl, windowName, 'left=50000,top=50000,width=0,height=0');
 
 printWindow.document.write(printContent.innerHTML);
 printWindow.document.close();
 printWindow.focus();
 printWindow.print();
 printWindow.close();
}
// -->
</script>






Call this printchart(DIVID) in Print Button onclientclick event.


regards,
Pal

check this forum.[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 13-Jan-12 23:53pm    
@anjutlya: this is not nice at all! What, you "saved" few seconds of your time and caused someone else to waste much more time for answering on a wrong topic. And you tell it only now! Please think about it.
--SA
Sergey Alexandrovich Kryukov 13-Jan-12 23:57pm    
And you cannot tell your are a beginner: you already asked 53 questions and answered, thus pretending to be an expert. Assuming those are real answers, you should better understand what do we feel if we waste out time on questions like that.
--SA
Sergey Alexandrovich Kryukov 13-Jan-12 23:52pm    
Look, we should stop attempting to answer any questions if OP does not properly specify type of application, UI library and other relevant detail which would exclude this kind of confusion. All type mentioned in the question should be written in fully-qualified form. We should request it and only answer when OP comply.

Multiple failures to specify such detail became a curse of this forum.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900