Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Printing a form/page

Printing a form/page

Scheduled Pinned Locked Moved Visual Basic
tutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LAYEEQ AHMED KHAN
    wrote on last edited by
    #1

    :confused:How to print the current form or a particular file by browsing the window simply by clicking on the button

    D T 2 Replies Last reply
    0
    • L LAYEEQ AHMED KHAN

      :confused:How to print the current form or a particular file by browsing the window simply by clicking on the button

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      You'r going to have to supply ALOT more detail than this. Printing the current form is no big deal, but what's with the "particular file by browsing the window simply by clicking on the button"? What are you talking about here. Code: Printing a Windows Form (Visual Basic)[^] on MSDN. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      1 Reply Last reply
      0
      • L LAYEEQ AHMED KHAN

        :confused:How to print the current form or a particular file by browsing the window simply by clicking on the button

        T Offline
        T Offline
        Treacherous_1
        wrote on last edited by
        #3

        Also you're going to have to let us know what version of VB you are using, for 6.0 printing the form is really simple (Me.printform), but in VB NET 2003 it's much more complicated. I had to do a project for a class that printed the form in 2003, utter chaos. I'll post the source later. Treacherous_1 Here's what I came up with, it enables print preview, page setup, and printing in .NET 2003: _________________________ Printing Form _____________________________ Imports System.Drawing.Printing Public Class frmMain Inherits System.Windows.Forms.Form ' storage for form image Dim formImage As Bitmap ' create API prototype 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 #Region " Windows Form Designer generated code " Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.StartPosition = FormStartPosition.WindowsDefaultLocation End Sub Private Sub mnuFilePrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFilePrint.Click GetFormImage() 'Takes the screen shot to be printed If pdbMgrReport.ShowDialog = DialogResult.OK Then docMgrReport.Print() End If End Sub Private Sub mnuFilePreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFilePreview.Click GetFormImage() 'Takes the screen shot to be previewed Try ppdMgrReport.ShowDialog() Catch es As Exception MessageBox.Show(es.Message) End Try End Sub Private Sub mnuFileSetup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileSetup.Click With psdMgrReport docMgrReport.DefaultPageSettings.Margins.Left = 0.5 docMgrReport.DefaultPageSettings.Margins.Top = 0.5 docMgrReport.DefaultPageSettings.Landscape = True .PageSettings = docMgrReport.DefaultPageSettings End With Try If psdMgrReport.ShowDialog = DialogResult.OK Then docMgrReport.DefaultPageSettings = psdMgrReport.PageSettings End If Catch es As Exception MessageBox.Show(es.Message)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups