各位:   我编写了一个小程序,只有一个form,上面布置了若干 textbox 等控件,请问不用其他打印控件,如何做到打印全部或部分数据?    我以前在哪儿见过类次代码,现忘了,请各位指教!谢谢!

解决方案 »

  1.   

    http://www.wave12.com/web/SigCon.asp?bCate=50&sCateName=%B9%A6%C4%DC%BD%E9%C9%DC&ID=173&CateName=wsReport4.5
      

  2.   

    谢谢 wxrwan(不耻上问)
    能否详细解释一下方法,我以前试过,没弄出来
     PrintForm方法谢谢
      

  3.   

    on error goto exitsub
    me.printfrom
    exitsub:
    exit sub 
    你试试这个
      

  4.   


    me.printfrom回打印全部啊,能否只打印窗体的部分区域啊?有没有这个功能!
      

  5.   

    放两个 PictureBox (不要嵌套)在窗体上。其中 Picture1 中放你要打印的各个控件。Picture2 放在它后面。Private Const twipFactor = 1440
    Private Const WM_PAINT = &HF
    Private Const WM_PRINT = &H317
    Private Const PRF_CLIENT = &H4&    ' Draw the window's client area.
    Private Const PRF_CHILDREN = &H10& ' Draw all visible child windows.
    Private Const PRF_OWNED = &H20&    ' Draw all owned windows.Private Declare Function SendMessage Lib "user32" Alias _
       "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
       ByVal wParam As Long, ByVal lParam As Long) As LongPrivate Sub Form_Load()
       Dim sWide As Single, sTall As Single
       Dim rv As Long   Me.ScaleMode = vbTwips   ' default
       sWide = 8.5
       stall = 11   ' or 14, etc.
       Me.Width = twipFactor * sWide
       Me.Height = twipFactor * stall
       With Picture1
          .Top = 0
          .Left = 0
          .Width = twipFactor * sWide
          .Height = twipFactor * stall
       End With
       With Picture2
          .Top = 0
          .Left = 0
          .Width = twipFactor * sWide
          .Height = twipFactor * stall
       End With   Me.Visible = True
    End SubPrivate cmdPrint_Click()
       Picture1.SetFocus
       Picture2.AutoRedraw = True
       rv = SendMessage(Picture1.hwnd, WM_PAINT, Picture2.hDC, 0)
       rv = SendMessage(Picture1.hwnd, WM_PRINT, Picture2.hDC, _
       PRF_CHILDREN + PRF_CLIENT + PRF_OWNED)
       Picture2.Picture = Picture2.Image
       Picture2.AutoRedraw = False   Printer.Print ""
       Printer.PaintPicture Picture2.Picture, 0, 0
       Printer.EndDoc
    End Sub
      

  6.   

    恩,办法都不错。。
    不过如果是我,我不会那么多操作啦,因为我懒麻!
    把需要打印的部分,都放在一个PICTUREBOX里面。然后打印PICTUERBOX就可以了。
      

  7.   

    picturebox怎么打印啊?没有提供打印方法 啊?