Dear Sir
I am very new for vb.net 2005, I am developing payroll application for school. In my application I have 1 database with many tables. There is table namely 'desig' it contains the information regarding the employee category and designation, I want to print list of the employee with there category and designation. I have manage to load data in a table and try to print but this code print only screen shot of the form not the content of the datagrid I don't know how to print the content of the datagrid can anybody help here is my code
I am very new for vb.net 2005, I am developing payroll application for school. In my application I have 1 database with many tables. There is table namely 'desig' it contains the information regarding the employee category and designation, I want to print list of the employee with there category and designation. I have manage to load data in a table and try to print but this code print only screen shot of the form not the content of the datagrid I don't know how to print the content of the datagrid can anybody help here is my code
Imports System.Data.OleDb
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Connection As New OleDb.OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data Source=c:\Brains_pay1\brainsp.mdb")
Dim sql As String = "SELECT * FROM desig"
Dim dataadapter As New OleDb.OleDbDataAdapter(sql, Connection)
Dim ds As New DataSet()
connection.Open()
dataadapter.Fill(ds, "desig")
connection.Close()
DataGridView1.DataSource = ds
DataGridView1.DataMember = "desig"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
PrintDocument1.Print()
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.DataGridView1.Width, Me.DataGridView1.Height)
DataGridView1.DrawToBitmap(bm, New Rectangle(0, 0, Me.DataGridView1.Width, Me.DataGridView1.Height))
e.Graphics.DrawImage(bm, 0, 0)
End Sub
End Class