Click here to Skip to main content
14,455,121 members
Rate this:
Please Sign up or sign in to vote.
See more:
during printing the receipt i am accessing datagridview content if rows are less than 35 then it prints all the contents of receipt but if when datagridview contents more rows then printer(dot matrix) gives problem ...
it prints only rows which fits in the one page ...on the starting of next page printer stops the printing
please help ...
Posted
Updated 7-Feb-14 0:19am
v2
Comments
G-code101 8-Feb-14 0:34am
   
What have you done so far? and where is the source code that you used? so I can see where you are getting stuck mate...
Member 10496260 20-Feb-14 3:23am
   
sorry for late
here is the code which i used for printing ...i am creating image of data and also uses panel for datagridview as datagridview row increases i am increasing the panel size also but its still giving problem ....



Public Class posbill
Private Sub data()

Try
If dgw1.Columns.Count = 0 Then
For Each dgvc As DataGridViewColumn In bill.dgw.Columns
dgw1.Columns.Add(TryCast(dgvc.Clone(), DataGridViewColumn))
Next
End If

Dim row As New DataGridViewRow()

For i As Integer = 0 To bill.dgw.Rows.Count - 1
row = DirectCast(bill.dgw.Rows(i).Clone(), DataGridViewRow)
Dim intColIndex As Integer = 0
For Each cell As DataGridViewCell In bill.dgw.Rows(i).Cells
row.Cells(intColIndex).Value = cell.Value
intColIndex += 1
Next
dgw1.Rows.Add(row)
Next
dgw1.AllowUserToAddRows = False

dgw1.Refresh()
Catch ex As Exception

End Try


End Sub

Private Sub possbill_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dgw1.Rows.Clear()

data()
'LoadReceipt()

lblinvooiceno.Text = bill.lblInvoiceNo.Text
lbldate.Text = bill.lbldate.Text
lbltotalcost.Text = bill.lblTotalCost.Text
lblcontactno.Text = bill.txtcntctno.Text
lblcustomerno.Text = bill.txtcustname.Text
lblRemaining.Text = bill.txtremaining.Text
PrintDialog1.Document = Me.PrintDocument1
Try
Dim ButtonPressed As DialogResult = PrintDialog1.ShowDialog()
If (ButtonPressed = DialogResult.OK) Then
PrintDocument1.Print()
End If
'Me.Close()

Catch ex As Exception


MsgBox(ex.Message)

End Try

End Sub

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim bm As New Bitmap(Me.Panel2.Width, Me.Panel2.Height)

Panel2.DrawToBitmap(bm, New Rectangle(0, 0, Me.Panel2.Width, Me.Panel2.Height))

e.Graphics.DrawImage(bm, 0, 0)
Dim aPS As New PageSetupDialog
aPS.Document = PrintDocument1
End Sub
Private Sub LoadReceipt()
Dim x As Integer = 0
Dim Y As Integer = 0
Try
sqL = "SELECT iDescription,UnitPrice,Quantity FROM Item as P, POSDetail as TD, POS as T WHERE TD.InvoiceNo = T.InvoiceNo AND T.InvoiceNo = '" & bill.lblInvoiceNo.Text & "' ORDER By ItemNo"
ConnDB()
cmd = New OleDbCommand(sqL, conn)
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
dgw1.Rows.Clear()

Do While dr.Read = True
dgw1.Rows.Add(dr("iDescription"), dr("UnitPrice"), dr("Quantity"))

dgw1.Height += 19
x += 19
Loop
Y = x - 30
dgw1.Height = dgw1.Height - 20

Panel2.Height = Panel2.Height + Y
Me.Height = Me.Height + Y
Me.Panel3.Location = New Point(9, 542 + Y)
Catch ex As Exception
MsgBox(ex.Message)
Finally
cmd.Dispose()
conn.Close()
End Try
End Sub

Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs)

End Sub
End Class

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100