各位高手,有谁知道怎么用vs.net 里面的打印预览控件?

解决方案 »

  1.   

    <html>
    <head>
    <style type="text/css" media="print">
    DIV.d1 { DISPLAY: none }
    </style>
    </head>
    <body>
    打印可以这样实现(仅作简单示例):
    也可把那个CAB文件下载到本地服务器再引用它.<br/>
    在这里加入打印内容及控制分页............
    <div class="d1">
    <OBJECT id="MyPrinter" style="DISPLAY: none" codeBase="http://www.meadroid.com/scriptx/ScriptX.cab#Version=5,60,0,360" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" viewastext>
    </OBJECT>
    <SCRIPT defer>
    function window.onload() {
    MyPrinter.printing.header = ""
    MyPrinter.printing.footer = ""
    MyPrinter.printing.portrait=true
    MyPrinter.printing.leftMargin =5
    MyPrinter.printing.topMargin = 5
    MyPrinter.printing.rightMargin = 1
    MyPrinter.printing.bottomMargin = 1
    //MyPrinter.printing.paperSize="Letter"
    }
    </SCRIPT>
    <input style="WIDTH: 87px; HEIGHT: 24px" onclick='document.execCommand("print")' type="button" value="打印...">
    <!--  <INPUT onclick=MyPrinter.printing.Print(false) type=button value=打印本頁> -->
    <input name="button" type="button" onClick="MyPrinter.printing.PageSetup()" value="页面设置">
    <INPUT onclick="MyPrinter.printing.Preview()" type="button" value="打印预览">  <br/>

    </div>
    </body>
    </html>
      

  2.   

    看看这个,有用没:
    <script language="javascript">  
      function printsetup(){  
      // 打印页面设置  
      wb.execwb(8,1);  
      }  
      function printpreview(){  
      // 打印页面预览  
      wb.execwb(7,1);  
      }  
      function printit()  
      {  
      if (confirm('确定打印吗?')) {  
      wb.execwb(6,6)  
      }  
      }  
      </script>  
      </head>  
      <body>  <OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"  height=0 id=wb name=wb width=0></OBJECT>  
      <input type=button name=button_print value="打印"  onclick="javascript:printit()">  
      <input type=button name=button_setup value="打印页面设置"  onclick="javascript:printsetup();">  
      <input type=button name=button_show value="打印预览"  onclick="javascript:printpreview();">  
      <input type=button name=button_fh value="关闭"  onclick="javascript:window.close();">
      

  3.   

    PrintPreviewDialog先设置你的PrintDocument
    然后再设置PrintPage事件
    还有打印机什么的
    就可以了