当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

    摘要: 在公共存储中可以进行窗体注册,可是邮箱的访问窗体如何注册成自定义的 呢? 用户的信息(邮件之类)在邮箱存储中到底是放在哪里的呢? 哪位能说说思路呢? ( 因为以前发的问题,有些没人答,分都浪费了所以先放40分 回答了会加的) ......
    摘要: 请大虾们帮帮忙 用odbc连接sql server 对多个表进行操作 该怎么做 谢谢 ......


大虾门:关于打印的问题

我在vb.net中做一个文件,做完后自动把文件送入打印机打印,vb.net中该用啥命令,请指教,另我想在javascript   trim一个字符串怎样实现,在线等。

NO.1   作者: jary12581

以下是打印richtext中的文本的例子:*******************************************    
  以下为打印部分的功能代码*************************************************  
   
          Private   Sub   printdoc_PrintPage(ByVal   sender   As   System.Object,   ByVal   e   As   System.Drawing.Printing.PrintPageEventArgs)   Handles   printdoc.PrintPage  
                  Dim   g   As   Graphics   定义指向Grapics的指针  
                  Dim   linesperpage   As   Long   定义每页中可打印的文本行数  
                  Dim   current   As   Long   定义打印的当前行  
                  Dim   y   As   Double   当前的纵坐标  
                  Dim   left   As   Double   定义左边距  
                  Dim   top   As   Double   定义顶边距  
                  Dim   stroutput   As   String   定义将要输出的文本  
                  Dim   printfont   As   System.Drawing.Font   定义打印字体  
                  Dim   brush   As   New   System.Drawing.SolidBrush(Color.Black)   定义打印时使用的刷子  
                  Dim   activechild   As   Form   定义当前活动的子窗体  
                  Dim   thebox   As   RichTextBox   定义子窗体中的RICHTEXTBOX控件  
   
                  activechild   =   Me.ActiveMdiChild   获得当前活动的SON窗体  
                  thebox   =   CType(activechild.ActiveControl,   RichTextBox)   获得当前活动子窗体中的控件  
                  printfont   =   thebox.Font   获得打印的字体  
                  g   =   e.Graphics   获得对象  
                  left   =   e.MarginBounds.Left   设置页面的左边距  
                  top   =   e.MarginBounds.   设置页面的顶边距  
                  linesperpage   =   e.MarginBounds.Height   /   printfont.GetHeight(g)   -   4   设置每页将要打印的行数,顶端空出两行用于打印标题,底煅空出两行用于打印注脚.  
                  y   =   top   设置打印的起始位置  
                  g.DrawString(activechild.Text,   printfont,   brush,   left,   y)   输出标题  
                  y   =   top   +   2   *   printfont.GetHeight(g)   设置正文的输出位置  
   
                  循环输出正文的每一行()  
                  While   current   <   linesperpage  
                          stroutput   =   line.ReadLine()   读取将要输出的内容  
                          If   Not   stroutput   Is   Nothing   Then   如果没有将要打印的内容,则中止循环  
                                  y   =   y   +   printfont.GetHeight(g)   计算将要输出的纵坐标的位置  
                                  g.DrawString(stroutput,   printfont,   brush,   left,   y)   输出正文  
                          Else  
                                  Exit   While  
                          End   If  
                  End   While  
                  y   =   e.MarginBounds.Bottom   -   printfont.GetHeight(g)   设置注脚的输出位置  
                  g.DrawString("footer",   printfont,   brush,   e.MarginBounds.Width   /   2,   y)   输出注脚  
                  If   Not   stroutput   Is   Nothing   Then   如果这一页没有打印完正文,则将属性设置为true,这将再一次激发printpage事件  
                          e.HasMorePages   =   True  
                  Else  
                          e.HasMorePages   =   False  
                  End   If  
          End   Sub  
          **************************以下为页面设置功能代码******************************  
   
          Private   Sub   menpagesetup_Click(ByVal   sender   As   System.Object,   ByVal   e   As   System.EventArgs)   Handles   menpagesetup.Click  
                  Dim   pagesetup   As   New   PageSetupDialog()  
                  pagesetup.Document   =   printdoc  
                  pagesetup.ShowDialog()  
          End   Sub  
          ******************************以下为打印设置功能代码************************  
   
          Private   Sub   menprintsetup_Click(ByVal   sender   As   System.Object,   ByVal   e   As   System.EventArgs)   Handles   menprintsetup.Click  
                  Dim   printersetup   As   New   PrintDialog()  
                  printersetup.Document   =   printdoc  
                  printersetup.ShowDialog()  
          End   Sub  
   
          ******************************以下为打印预览功能代码************************  
   
          Private   Sub   menprintview_Click(ByVal   sender   As   System.Object,   ByVal   e   As   System.EventArgs)   Handles   menprintview.Click  
                  Dim   activechild   As   Form   =   Me.ActiveMdiChild  
                  If   Not   activechild   Is   Nothing   Then  
                          Dim   preview   As   New   PrintPreviewDialog()  
                          Me.PrintPreviewDialog1.Document   =   printdoc  
                          Dim   thebox   As   RichTextBox  
                          thebox   =   CType(activechild.ActiveControl,   RichTextBox)  
                          line   =   New   System.IO.StringReader(thebox.Text)  
                          Try  
                                  Me.PrintPreviewDialog1.StartPosition   =   FormStartPosition.CenterScreen  
                                  Me.PrintPreviewDialog1.ShowDialog()  
                          Catch   e1   As   Exception  
                                  MsgBox(e1.StackTrace)  
                          End   Try  
                  End   If  
          End   Sub  
          *******************************以下为打印功能的代码*****************************  
   
          Private   Sub   menprint_Click(ByVal   sender   As   System.Object,   ByVal   e   As   System.EventArgs)   Handles   menprint.Click  
                  Dim   activechild   As   Form   =   Me.ActiveMdiChild  
                  If   Not   activechild   Is   Nothing   Then  
                          Dim   printersetup   As   New   PrintDialog()  
                          printersetup.Document   =   printdoc  
                          If   printersetup.ShowDialog()   =   DialogResult.OK   Then  
                                  Dim   thebox   As   RichTextBox  
                                  thebox   =   CType(activechild.ActiveControl,   RichTextBox)  
                                  line   =   New   System.IO.StringReader(thebox.Text)   初始化字符串流  
                                  Try  
                                          printdoc.Print()  
                                  Catch   e1   As   Exception  
                                          MsgBox(e1.StackTrace)  
                                          printdoc.PrintController.OnEndPrint(printdoc,   e)  
                                  End   Try  
                          End   If  
                  End   If  
          End   Sub


 ·求一个代码谢谢    »显示摘要«
    摘要: 我想要这样一个咚咚.他可以收集平时我看到的一个些好的代码.需要的时候可以随时调出来,还可以查询.谢谢 ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE