Printing a form/page
-
:confused:How to print the current form or a particular file by browsing the window simply by clicking on the button
-
:confused:How to print the current form or a particular file by browsing the window simply by clicking on the button
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
-
:confused:How to print the current form or a particular file by browsing the window simply by clicking on the button
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)