Can Some be kind enogh Input Printing feature in my application

Fas

Member
Joined
Mar 27, 2006
Messages
15
Programming Experience
Beginner
Last Nite rockwell was great and he added print feature to my application unfortunately i cant open it becuse it was created in a newer version on vs or something (see thread befor this) neways i attach my program if some1 fancy a go plzz do
ITS ONLY 1 FORM I WANT 2 PRINT
Im usin VS 2003 1.1 FRAMEWORK

THANX
 

Attachments

  • WindowsApplication1.zip
    147.3 KB · Views: 27
ok dude, if you do the way i say u can print your form. Initially add a print button to your application, name it Print(coz thats what i used in the code), then go to the tool box and add a printdialog onto your form and it automatically shows the name as printdialog1. Then just replace the code below with ur code(dont forget to take a backup)

VB.NET:
Imports System.Drawing.Printing
Public Class Form1
Inherits System.Windows.Forms.Form
Private PicForm As PictureBox
Private blnFirstTimeThrough As Boolean = True
Friend WithEvents Pd As System.Drawing.Printing.PrintDocument
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer. 
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents LbResult As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Label9 As System.Windows.Forms.Label
Friend WithEvents LbResult2 As System.Windows.Forms.Label
Friend WithEvents LbTax As System.Windows.Forms.TextBox
Friend WithEvents LbIns As System.Windows.Forms.TextBox
Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents Label8 As System.Windows.Forms.Label
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents Label10 As System.Windows.Forms.Label
Friend WithEvents CrystalReportViewer1 As CrystalDecisions.Windows.Forms.CrystalReportViewer
Friend WithEvents Print As System.Windows.Forms.Button
Friend WithEvents PrintDialog1 As System.Windows.Forms.PrintDialog
Friend WithEvents PrintDocument1 As System.Drawing.Printing.PrintDocument
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.TextBox3 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.LbResult = New System.Windows.Forms.Label
Me.Label9 = New System.Windows.Forms.Label
Me.Label5 = New System.Windows.Forms.Label
Me.Button2 = New System.Windows.Forms.Button
Me.LbResult2 = New System.Windows.Forms.Label
Me.LbTax = New System.Windows.Forms.TextBox
Me.LbIns = New System.Windows.Forms.TextBox
Me.ListBox1 = New System.Windows.Forms.ListBox
Me.Label4 = New System.Windows.Forms.Label
Me.Label6 = New System.Windows.Forms.Label
Me.Label7 = New System.Windows.Forms.Label
Me.Label8 = New System.Windows.Forms.Label
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.Label10 = New System.Windows.Forms.Label
Me.CrystalReportViewer1 = New CrystalDecisions.Windows.Forms.CrystalReportViewer
Me.PrintDocument1 = New System.Drawing.Printing.PrintDocument
Me.Print = New System.Windows.Forms.Button
Me.PrintDialog1 = New System.Windows.Forms.PrintDialog
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.ForeColor = System.Drawing.SystemColors.ActiveCaption
Me.Label1.Location = New System.Drawing.Point(8, 144)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(152, 16)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Staff ID"
'
'Label2
'
Me.Label2.Font = New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.ForeColor = System.Drawing.SystemColors.ActiveCaption
Me.Label2.Location = New System.Drawing.Point(8, 184)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(152, 24)
Me.Label2.TabIndex = 1
Me.Label2.Text = "Hours Worked"
'
'Label3
'
Me.Label3.Font = New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label3.ForeColor = System.Drawing.SystemColors.ActiveCaption
Me.Label3.Location = New System.Drawing.Point(8, 232)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(152, 24)
Me.Label3.TabIndex = 2
Me.Label3.Text = "Wage Per Hour"
'
'TextBox1
'
Me.TextBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.TextBox1.ForeColor = System.Drawing.Color.Red
Me.TextBox1.Location = New System.Drawing.Point(176, 136)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(112, 26)
Me.TextBox1.TabIndex = 3
Me.TextBox1.Text = "Enter"
'
'TextBox2
'
Me.TextBox2.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.TextBox2.ForeColor = System.Drawing.Color.Red
Me.TextBox2.Location = New System.Drawing.Point(176, 184)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(112, 26)
Me.TextBox2.TabIndex = 4
Me.TextBox2.Text = "View Info Bar"
'
'TextBox3
'
Me.TextBox3.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.TextBox3.ForeColor = System.Drawing.Color.Red
Me.TextBox3.Location = New System.Drawing.Point(176, 224)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(112, 26)
Me.TextBox3.TabIndex = 5
Me.TextBox3.Text = "View Info Bar"
'
'Button1
'
Me.Button1.BackColor = System.Drawing.Color.Lime
Me.Button1.Cursor = System.Windows.Forms.Cursors.Hand
Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.Button1.Font = New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button1.ForeColor = System.Drawing.SystemColors.InfoText
Me.Button1.Location = New System.Drawing.Point(8, 272)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(144, 40)
Me.Button1.TabIndex = 6
Me.Button1.Text = "Wage"
Me.Button1.UseVisualStyleBackColor = False
'
'LbResult
'
Me.LbResult.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.LbResult.ForeColor = System.Drawing.SystemColors.InfoText
Me.LbResult.Location = New System.Drawing.Point(168, 272)
Me.LbResult.Name = "LbResult"
Me.LbResult.Size = New System.Drawing.Size(120, 40)
Me.LbResult.TabIndex = 7
Me.LbResult.Text = "Displays Here"
'
'Label9
'
Me.Label9.Font = New System.Drawing.Font("Times New Roman", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label9.Location = New System.Drawing.Point(8, 328)
Me.Label9.Name = "Label9"
Me.Label9.Size = New System.Drawing.Size(312, 40)
Me.Label9.TabIndex = 8
Me.Label9.Text = "Canculate Gross Pay = (Wage - 20% Tax - 7% Natio" & _
"nal Insurance)"
'
'Label5
'
Me.Label5.Font = New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label5.Location = New System.Drawing.Point(8, 96)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(408, 24)
Me.Label5.TabIndex = 9
Me.Label5.Text = "Canculate Wage (Wage Per Hour x Hours Worked)"
'
'Button2
'
Me.Button2.BackColor = System.Drawing.Color.Lime
Me.Button2.Cursor = System.Windows.Forms.Cursors.Hand
Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.Button2.Font = New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button2.ForeColor = System.Drawing.SystemColors.InfoText
Me.Button2.Location = New System.Drawing.Point(8, 464)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(144, 40)
Me.Button2.TabIndex = 10
Me.Button2.Text = "Gross Pay"
Me.Button2.UseVisualStyleBackColor = False
'
'LbResult2
'
Me.LbResult2.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.LbResult2.ForeColor = System.Drawing.SystemColors.InfoText
Me.LbResult2.Location = New System.Drawing.Point(160, 464)
Me.LbResult2.Name = "LbResult2"
Me.LbResult2.Size = New System.Drawing.Size(128, 40)
Me.LbResult2.TabIndex = 14
Me.LbResult2.Text = "Displays Here"
'
'LbTax
'
Me.LbTax.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.LbTax.ForeColor = System.Drawing.Color.Red
Me.LbTax.Location = New System.Drawing.Point(208, 384)
Me.LbTax.Name = "LbTax"
Me.LbTax.Size = New System.Drawing.Size(56, 26)
Me.LbTax.TabIndex = 16
Me.LbTax.Text = "20%"
'
'LbIns
'
Me.LbIns.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.LbIns.ForeColor = System.Drawing.Color.Red
Me.LbIns.Location = New System.Drawing.Point(208, 416)
Me.LbIns.Name = "LbIns"
Me.LbIns.Size = New System.Drawing.Size(56, 26)
Me.LbIns.TabIndex = 17
Me.LbIns.Text = "7%"
'
'ListBox1
'
Me.ListBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ListBox1.ItemHeight = 20
Me.ListBox1.Items.AddRange(New Object() {"I N F O B A R", "Hours Worked" & Global.Microsoft.VisualBasic.ChrW(9) & "Pay Rate", "36+ Hours" & Global.Microsoft.VisualBasic.ChrW(9) & "£7.45 ", "44 Hours " & Global.Microsoft.VisualBasic.ChrW(9) & Global.Microsoft.VisualBasic.ChrW(9) & "£10.32", "45+ Hours" & Global.Microsoft.VisualBasic.ChrW(9) & "£15.66 "})
Me.ListBox1.Location = New System.Drawing.Point(328, 128)
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.Size = New System.Drawing.Size(224, 104)
Me.ListBox1.TabIndex = 18
'
'Label4
'
Me.Label4.Font = New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label4.ForeColor = System.Drawing.SystemColors.ActiveCaption
Me.Label4.Location = New System.Drawing.Point(8, 384)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(192, 24)
Me.Label4.TabIndex = 19
Me.Label4.Text = "Tax Deduction"
'
'Label6
'
Me.Label6.Font = New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label6.ForeColor = System.Drawing.SystemColors.ActiveCaption
Me.Label6.Location = New System.Drawing.Point(8, 424)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(192, 24)
Me.Label6.TabIndex = 20
Me.Label6.Text = "Insurance Deduction"
'
'Label7
'
Me.Label7.Font = New System.Drawing.Font("Times New Roman", 20.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label7.Location = New System.Drawing.Point(16, 16)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(320, 40)
Me.Label7.TabIndex = 21
Me.Label7.Text = "BestWay Pay Calculator"
Me.Label7.TextAlign = System.Drawing.ContentAlignment.TopCenter
'
'Label8
'
Me.Label8.Font = New System.Drawing.Font("Times New Roman", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label8.ForeColor = System.Drawing.Color.Red
Me.Label8.Location = New System.Drawing.Point(336, 24)
Me.Label8.Name = "Label8"
Me.Label8.Size = New System.Drawing.Size(248, 24)
Me.Label8.TabIndex = 22
Me.Label8.Text = "Copyrights Fa$ Software Ltd"
'
'PictureBox1
'
Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
Me.PictureBox1.Location = New System.Drawing.Point(312, 240)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(264, 304)
Me.PictureBox1.TabIndex = 23
Me.PictureBox1.TabStop = False
'
'Label10
'
Me.Label10.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label10.ForeColor = System.Drawing.Color.Red
Me.Label10.Location = New System.Drawing.Point(16, 56)
Me.Label10.Name = "Label10"
Me.Label10.Size = New System.Drawing.Size(136, 16)
Me.Label10.TabIndex = 24
Me.Label10.Text = "Version 1.0"
'
'CrystalReportViewer1
'
Me.CrystalReportViewer1.ActiveViewIndex = -1
Me.CrystalReportViewer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.CrystalReportViewer1.Location = New System.Drawing.Point(0, 0)
Me.CrystalReportViewer1.Name = "CrystalReportViewer1"
Me.CrystalReportViewer1.SelectionFormula = ""
Me.CrystalReportViewer1.Size = New System.Drawing.Size(150, 150)
Me.CrystalReportViewer1.TabIndex = 0
Me.CrystalReportViewer1.ViewTimeSelectionFormula = ""
'
'PrintDocument1
'
Me.PrintDocument1.DocumentName = "Form1"
Me.PrintDocument1.OriginAtMargins = True
'
'Print
'
Me.Print.Location = New System.Drawing.Point(532, 56)
Me.Print.Name = "Print"
Me.Print.Size = New System.Drawing.Size(64, 31)
Me.Print.TabIndex = 25
Me.Print.Text = "Print"
Me.Print.UseVisualStyleBackColor = True
'
'PrintDialog1
'
Me.PrintDialog1.UseEXDialog = True
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.SystemColors.ControlLightLight
Me.ClientSize = New System.Drawing.Size(608, 578)
Me.Controls.Add(Me.Print)
Me.Controls.Add(Me.Label10)
Me.Controls.Add(Me.PictureBox1)
Me.Controls.Add(Me.Label8)
Me.Controls.Add(Me.Label7)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.ListBox1)
Me.Controls.Add(Me.LbIns)
Me.Controls.Add(Me.LbTax)
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.LbResult2)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.Label9)
Me.Controls.Add(Me.LbResult)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Cursor = System.Windows.Forms.Cursors.Arrow
Me.Name = "Form1"
Me.Text = "BestWay Pay Calculator"
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
#End Region
Private Sub InitializeFormForPrinting()
'System.Threading.Thread.Sleep(5)
'PrintDialog1.ShowDialog()
PicForm = New PictureBox
End Sub
Public Overloads Sub PrintForm(ByVal TheForm As Form, ByVal ButtonVisibility As Boolean, Optional ByVal Printer As String = "")
If blnFirstTimeThrough Then
InitializeFormForPrinting()
blnFirstTimeThrough = False
End If
If ButtonVisibility = False Then
Call ButtonMagic(TheForm, False)
End If
'System.Threading.Thread.Sleep(5)
'Now, save active form as bmp to the 
'clipboard by simulating <Alt> <Prt Sc> keystrokes
'SendKeys.SendWait("%{ALT}")
SendKeys.SendWait("%{PRTSC}")
'get clipboard image and put it in a picturebox
PicForm.Image = DirectCast(System.Windows.Forms.Clipboard.GetDataObject.GetData _
(System.Windows.Forms.DataFormats.Bitmap), Bitmap)
Try
If Printer.Length > 0 Then Pd.PrinterSettings.PrinterName = Printer
Pd.Print()
Catch err As Exception
MessageBox.Show(err.ToString(), "Print Error!", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
Call ButtonMagic(TheForm, True)
End Try
End Sub
Public Overloads Sub PrintForm(ByVal TheForm As Form, Optional ByVal Printer As String = "")
If blnFirstTimeThrough Then
InitializeFormForPrinting()
blnFirstTimeThrough = False
End If
Call ButtonMagic(TheForm, True)
'System.Threading.Thread.Sleep(5)
'Now, save active form as bmp to the 
'clipboard by simulating <Alt> <Prt Sc> keystrokes
'SendKeys.SendWait("%{ALT}")
SendKeys.SendWait("%{PRTSC}")
'get clipboard image and put it in a picturebox
PicForm.Image = DirectCast(System.Windows.Forms.Clipboard.GetDataObject.GetData _
(System.Windows.Forms.DataFormats.Bitmap), Bitmap)
Try
If Printer.Length > 0 Then Pd.PrinterSettings.PrinterName = Printer
Pd.Print()
Catch err As Exception
MessageBox.Show(err.ToString(), "Print Error!", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
Call ButtonMagic(TheForm, True)
End Try
End Sub
Private Sub ButtonMagic(ByVal TheContainer As Control, ByVal ButtonVisibility As Boolean)
Dim c As Control
'Dim mnu As Men
' Look at each of the controls in the form or in the current container
For Each c In TheContainer.Controls
' If the control is itself a container then call the ButtonMagic
' and give it the new container to iterate
If Not c.Controls Is Nothing Then
ButtonMagic(c, ButtonVisibility)
End If
'If the control is a command button, check the desired visibility
'and change all buttons to that setting
If TypeOf c Is Button Then
If ButtonVisibility = True Then
c.Visible = False
Else
c.Visible = False
End If
End If
' If TypeOf mnu Is Menu Then
' mnu.MenuItems. = False
' End If
Next
End Sub
Private Sub Pd_BeginPrint(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles Pd.BeginPrint
Pd.DefaultPageSettings.Landscape = False
Dim sz As SizeF = PicForm.Image.GetBounds(GraphicsUnit.Pixel).Size
Dim pw As Integer = Pd.DefaultPageSettings.Bounds.Width
pw -= Pd.DefaultPageSettings.Margins.Left
pw -= Pd.DefaultPageSettings.Margins.Right
'landscape if image unscaled is wider than marginbounds width
If sz.Width > pw Then Pd.DefaultPageSettings.Landscape = True
End Sub
Private Sub pd_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles Pd.PrintPage
'Dim c As Control
Dim thecontrol As Control
Dim mnu As MenuItem
Dim frm As Form1
Dim sz As SizeF = PicForm.Image.GetBounds(GraphicsUnit.Pixel).Size
'scale image if it unscaled doesn't fit marginbounds
If sz.Height > e.MarginBounds.Size.Height Or sz.Width > e.MarginBounds.Size.Width Then
Dim scaleheight As Double = sz.Height / e.MarginBounds.Size.Height
Dim scalewidth As Double = sz.Width / e.MarginBounds.Size.Width
Dim scale As Double = Math.Max(scalewidth, scaleheight)
scalewidth = sz.Width / scale
scaleheight = sz.Height / scale
sz = New SizeF(scalewidth, scaleheight)
Dim scalebounds As New RectangleF(e.MarginBounds.Location, sz)
'draw scaled image
e.Graphics.DrawImage(PicForm.Image, scalebounds)
Else
'draw unscaled image
e.Graphics.DrawImageUnscaled(PicForm.Image, e.MarginBounds)
End If
e.HasMorePages = False 'this is the last page to print
For Each c As Control In Me.Controls
If TypeOf c Is Button Then
c.Visible = True
End If
'If TypeOf mnu Is MenuItem Then
' mnu.Visible = True
'End If
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim result As Double = Val(TextBox2.Text) * Val(TextBox3.Text)
LbResult.Text = String.Format("{0:n2}", result)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim result As Double = Val(TextBox2.Text) * Val(TextBox3.Text)
LbResult.Text = String.Format("{0:n2}", result)
Dim result2 As Double = Val(LbResult.Text) - Val(LbTax.Text) - Val(LbIns.Text)
LbResult2.Text = String.Format("{0:n2}", result2)
End Sub
Private Sub Print_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Print.Click
PrintDialog1.Document = Pd
If PrintDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
'System.Threading.Thread.Sleep(10)
PrintForm(Me, PrintDialog1.PrinterSettings.PrinterName)
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Pd = New System.Drawing.Printing.PrintDocument
End Sub
End Class

--kris
 
i got errors

types or decleration expected errors thanx 4 ur help mate butstill stuck attaced is d program with ur code dude
 

Attachments

  • WindowsApplicationNewCode.zip
    184 KB · Views: 28
oh i see, the reason u r getting these errors is because thats a full statement and when i copied it here, it couldnt come in a single line and so became multiple lines. Just go to where you are getting the errors and try to put them in a single line ..........

HTH
--kris
 
Stil Erorors View Screnshot Attacement Rock

Stil Got Erors D D 1line Thing 21 Left Errors
 

Attachments

  • sCREENsHOT.doc
    83.5 KB · Views: 33
  • sCREENsHOT TOP.doc
    86 KB · Views: 31
:cool: T-r-y this ( =Me :p ) 1 4 pd sup, d mod u 1st saw. :rolleyes: n if me line took u > 1 zec 2 read :eek: :eek: , mayB :confused: u c it is not a way 2 Bhave :mad: 2 otherz her-. :confused: :rolleyes: :) ;)
 

Attachments

  • WindowsApplication1.zip
    37.2 KB · Views: 33
Im Sorry

Dear JohnH and other forum Users,
after seeing johnhs last post where he was great and sorted my application out (thanks john) i would also like to thanks others who have help me. rockwell you are a top man. thanks everyone for helping me.
SORRY
if my behaviour offended you, my tone of language is not to offend or cause problems .. i understand were you are coming from john, i'm sorry.

Please accept my appology and thank you so much for all your help u all been great
 
Last edited by a moderator:
Dear Fas, don't be so upset, cheer up, you are making great progress here. Understand that the complain is not only about the probable majority of native englishmen here versus those not. If you managed to decifer my message, you found out that it just takes too long time to read to bother. In which case you most likely will not get the help you ask for.
 
Back
Top