i want to print a particular record from datagridview to y bill-VBForums
Results 1 to 4 of 4

Thread: i want to print a particular record from datagridview to y bill

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2013
    Posts
    4

    i want to print a particular record from datagridview to y bill

    i want to print a particular selected record from a datagridview to my bill how to do that please help out on this
    Attached Images Attached Images  

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    21,507

    Re: i want to print a particular record from datagridview to y bill

    How far have you got?
    Do you have the fields from the row, or do you need help with that?
    Do you know how to print a bill, or do you need help with that?

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2013
    Posts
    4

    Re: i want to print a particular record from datagridview to y bill

    i need all the details if you can help me on that for my future reference if it possible. thank you o much for the help

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    21,507

    Re: i want to print a particular record from datagridview to y bill

    Something like this...

    Code:
    Public Class Form1
    
        Private WithEvents pd As New Printing.PrintDocument
        Private ppd As PrintPreviewDialog
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            DataGridView1.Rows.Add(29, Now.ToString("dd/MM/yyyy"), "BALENO", 123456789, "A Customer", "Agent Million", "Danbury", Now.ToString("dd/MM/yyyy"), Now.ToString("hh:mm:ss"), 0)
        End Sub
    
        Private Sub pd_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles pd.PrintPage
            Dim row As DataGridViewRow = DataGridView1.CurrentRow
            Dim x As Integer = e.MarginBounds.X
            Dim y As Integer = e.MarginBounds.Y
            Dim titleFont As Font = New Font(Me.Font.Name, 25, FontStyle.Bold, GraphicsUnit.Pixel)
            e.Graphics.DrawString("Your Bill", titleFont, Brushes.Black, x, y)
            x += 300
            y += 10
            e.Graphics.DrawString(row.Cells(1).Value.ToString, Me.Font, Brushes.Black, x, y)
            x -= 300
            y += 90
            e.Graphics.DrawString(row.Cells(0).Value.ToString, Me.Font, Brushes.Black, x, y)
            x += 50
            e.Graphics.DrawString(row.Cells(2).Value.ToString, Me.Font, Brushes.Black, x, y)
            x += 100
            e.Graphics.DrawString(row.Cells(3).Value.ToString, Me.Font, Brushes.Black, x, y)
            x -= 150
            y += 20
            e.Graphics.DrawString(row.Cells(4).Value.ToString, Me.Font, Brushes.Black, x, y)
            y += 20
            e.Graphics.DrawString(row.Cells(5).Value.ToString, Me.Font, Brushes.Black, x, y)
            x += 150
            e.Graphics.DrawString(row.Cells(6).Value.ToString, Me.Font, Brushes.Black, x, y)
            y += 20
            x -= 150
            e.Graphics.DrawString(row.Cells(7).Value.ToString, Me.Font, Brushes.Black, x, y)
            x += 150
            e.Graphics.DrawString(row.Cells(8).Value.ToString, Me.Font, Brushes.Black, x, y)
            x += 200
            e.Graphics.DrawString(row.Cells(9).Value.ToString, Me.Font, Brushes.Black, x, y)
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            ppd = New PrintPreviewDialog
            ppd.WindowState = FormWindowState.Maximized
            ppd.Document = pd
            ppd.ShowDialog()
            'to print without using the PrintPreviewDialog, use this...
            'pd.Print()
        End Sub
    
    End Class

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.