• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 252
  • Last Modified:

PRINTING A FORM IN VB.NET 2003

HI,

I'M TRYING TO PRINT MY FORM (SCREEN SHOT) BUT I CANNOT FIND THE WAY TO DO IT WITH VB.NET.  I THINK IT WAS TO SIMPLE IN VB 6.0 WITH THE PRINTFORM METHOD...  RIGHT NOW, I'M VERY CONFUSED BEACAUSE ALL iWANT TO DO IS PRINT MY FORM AFTER A CLICK ON A BUTTON.  IS THERE ANYONE WHO CAN TELL ME...

THANKS

CHRIS
0
chris_nephew
Asked:
chris_nephew
1 Solution
 
TorrwinCommented:
You need to add a print dialog control to your page, drag it from the toolbox and drop it onto the form.  Then search VB's help section for "print dialog" for examples.
0
 
YZlatCommented:
Import System.Drawing.Printing, then drag a PrintForm component and a standard .NET PrintPreviewDialog from the Toolbox to the Form
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
YZlatCommented:
PrintForm component has to be downloaded separately:

http://www.dnzone.com/ShowDetail.asp?NewsId=147
0
 
chris_nephewAuthor Commented:
My problem is that I want to print my form
I add this to my code

Import System.Drawing.Printing
I have a printdocument control and a print dialog control
How do I ser those controls to print the form!!!

Chris
0
 
YZlatCommented:
try this:

printDoc.DocumentName = fileName
printDoc.Print()
0
 
YZlatCommented:

    PrintDialog1 = New PrintDialog()
    PrintDialog1.Document = PrintDoc
     
    Dim r As DialogResult = PrintDialog1.ShowDialog
     
    If r = DialogResult.OK Then
        printDoc.DocumentName = fileName
        PrintDoc.Print()
    End If

0
 
chris_nephewAuthor Commented:
When you say
printdoc.documentName = filename

what is filename?  I mean is it the name of my form (ex : form1.vb) or is it something else!!

thanks

Chris
0
 
chris_nephewAuthor Commented:
because right now I'm printing blank page!!!

Christian
0
 
planoczCommented:
Sample Place in form....


'FORM 1

Imports System.IO
Imports System.Drawing.Imaging

 Private memoryImage As Bitmap
 'For Capture Screen Info.
    Private Declare Function BitBlt Lib "gdi32.dll" Alias "BitBlt" (ByVal _
      hdcDest As IntPtr, ByVal nXDest As Integer, ByVal nYDest As _
      Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal _
      hdcSrc As IntPtr, ByVal nXSrc As Integer, ByVal nYSrc As Integer, _
      ByVal dwRop As System.Int32) As Long

 Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
          CaptureScreen()
  End Sub


'Now that you have a file to read just go print it.
 Private Sub CaptureScreen()
        Dim mygraphics As Graphics = Me.CreateGraphics()
        'Use this for the whole screen
        Dim s As Size = Me.Size
        memoryImage = New Bitmap(s.Width, s.Height, mygraphics)
        'use this for the size of 750x880
        ' memoryImage = New Bitmap(150, 150, mygraphics)
        Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage)
        Dim dc1 As IntPtr = mygraphics.GetHdc
        Dim dc2 As IntPtr = memoryGraphics.GetHdc
        'use this for regular size
        BitBlt(dc2, 0, 0, Me.ClientRectangle.Width, Me.ClientRectangle.Height, dc1, 0, 0, 13369376)
        'use this for size adjust on top of screen
        'BitBlt(dc2, 0, -50, Me.ClientRectangle.Width, Me.ClientRectangle.Height, dc1, 0, 0, 13369376)
        mygraphics.ReleaseHdc(dc1)
        memoryGraphics.ReleaseHdc(dc2)
        memoryImage.Save("C:\MYPATH\test.bmp", ImageFormat.Bmp)
    End Sub



0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now