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
V

vinidimple

@vinidimple
About
Posts
7
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • print a form which contains a tab control
    V vinidimple

    Hi This is to print a form which contains a tab control.For this you have to instal Microsoft.Visual Basic.PowerPacks.Printing.dll.Then add one command button and a tab control to your form.Then add some other controls to your tabpages.Drag PrintDocument1 control from the tool box to your form.After that paste the code in the code behind.Press F5 to run it.Click on the button1 to print the pages. Option Strict Off Imports System.Drawing Imports System.Drawing.Printing Imports System.Runtime.InteropServices Public Class Form1 Dim TabId As Integer Dim i As Integer Dim img As Bitmap Dim WithEvents pd As PrintDocument Public Sub New() ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.TabControl1.SelectTab(0) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try TabId = Me.TabControl1.TabCount For i = 0 To TabId - 1 Me.TabControl1.TabIndex = i Me.TabControl1.SelectTab(i) 'MsgBox(i) Me.Refresh() img = CaptureForm1() pd = New PrintDocument pd.Print() Next Catch ex As Exception MsgBox(ex) End Try End Sub Function CaptureForm1() As Bitmap Dim g1 As Graphics = Me.CreateGraphics() Dim MyImage = New Bitmap(Me.ClientRectangle.Width, (Me.ClientRectangle.Height), g1) Dim g2 As Graphics = Graphics.FromImage(MyImage) Dim dc1 As IntPtr = g1.GetHdc() Dim dc2 As IntPtr = g2.GetHdc() BitBlt(dc2, 0, 0, Me.ClientRectangle.Width, (Me.ClientRectangle.Height), dc1, 0, 0, 13369376) g1.ReleaseHdc(dc1) g2.ReleaseHdc(dc2) 'saves image to c drive just, u can comment it also MyImage.Save("c:\abc.bmp") Return MyImage End Function Sub pd_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs) Handles pd.PrintPage Dim x As Integer = e.MarginBounds.X Dim y As Integer = e.MarginBounds.Y e.Graphics.DrawImage(img, x, y) e.HasMorePages = False End Sub SetLastError:=True, CharSet:=CharSet.Unicode, _ ExactSpelling:=True, _ CallingConvention:=CallingConvention.StdCall)> _ Private Shared Function 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 Boolean ' Leave function empty - DLLImport attribute forwards calls to MoveFile to ' MoveFil

    Article Writing graphics

  • How to print a form in vb.net with multiple tab pages!!
    V vinidimple

    Hi This is to print a form which contains a tab control.For this you have to instal Microsoft.Visual Basic.PowerPacks.Printing.dll.Then add one command button and a tab control to your form.Then add some other controls to your tabpages.Drag PrintDocument1 control from the tool box to your form.After that paste the code in the code behind.Press F5 to run it.Click on the button1 to print the pages. Option Strict Off Imports System.Drawing Imports System.Drawing.Printing Imports System.Runtime.InteropServices Public Class Form1 Dim TabId As Integer Dim i As Integer Dim img As Bitmap Dim WithEvents pd As PrintDocument Public Sub New() ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.TabControl1.SelectTab(0) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try TabId = Me.TabControl1.TabCount For i = 0 To TabId - 1 Me.TabControl1.TabIndex = i Me.TabControl1.SelectTab(i) 'MsgBox(i) Me.Refresh() img = CaptureForm1() pd = New PrintDocument pd.Print() Next Catch ex As Exception MsgBox(ex) End Try End Sub Function CaptureForm1() As Bitmap Dim g1 As Graphics = Me.CreateGraphics() Dim MyImage = New Bitmap(Me.ClientRectangle.Width, (Me.ClientRectangle.Height), g1) Dim g2 As Graphics = Graphics.FromImage(MyImage) Dim dc1 As IntPtr = g1.GetHdc() Dim dc2 As IntPtr = g2.GetHdc() BitBlt(dc2, 0, 0, Me.ClientRectangle.Width, (Me.ClientRectangle.Height), dc1, 0, 0, 13369376) g1.ReleaseHdc(dc1) g2.ReleaseHdc(dc2) 'saves image to c drive just, u can comment it also MyImage.Save("c:\abc.bmp") Return MyImage End Function Sub pd_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs) Handles pd.PrintPage Dim x As Integer = e.MarginBounds.X Dim y As Integer = e.MarginBounds.Y e.Graphics.DrawImage(img, x, y) e.HasMorePages = False End Sub

    Windows Forms graphics csharp tutorial

  • Error while opening project
    V vinidimple

    Hi Sorry i was trying to send the request through each forum but error page displays,so i go for multiple requests,yes thank you i got he answer through google thank you dimp dimp

    ASP.NET help question

  • Error While opening a Dot net Project
    V vinidimple

    Hi I am facing one problem while opening my Dot net project ?Error is coming like there "There is error on 1 Line:Expected '<' but found Auto attach" and the corresponding project file is not a valid project. if anybody knows please help me out dimp

    C# help question

  • Error while opening project
    V vinidimple

    Hi I am facing one problem while opening my Dot net project ?Error is coming like there "There is error on 1 Line:Expected '<' but found Auto attach" and the corresponding project file is not a valid project. if anybody knows please help me out dimp dimp dimp

    ASP.NET help question

  • Error while opening DotNet project
    V vinidimple

    Hi I am facing one problem while opening my Dot net project ?Error is coming like there "There is error on 1 Line:Expected '<' but found Auto attach" and the corresponding project file is not a valid project. if anybody knows please help me out dimp dimp

    .NET (Core and Framework) help csharp question

  • Regarding Dot net
    V vinidimple

    Hi I am facing one problem while opening my Dot net project ?Error is coming like there "There is error on 1 Line:Expected '<' but found Auto attach" and the corresponding project file is not a valid project. if anybody knows please help me out dimp

    IT & Infrastructure help question
  • Login

  • Don't have an account? Register

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