pls i designed a database application using visual basic. i have done the coding for the print incase i want to print out the data.
Pls my problem is how to code at design time for the application to print the data in a tabular form. for now the records prints ontop of each other, i want the records and the field separated by rows and cells of a table as normal.
I used Ms access to design the database and the data is displayed by datagrid view. my code so far is as shown below. pls help me make correction to be able to achieve the above display - Public Class AccountView
-
-
Private Sub BtnPDVPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPDVPrint.Click
-
Dim print_document As PrintDocument = PreparePrintDocument()
-
-
print_document.Print()
-
If dlgPrint.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
-
dlgPrint.Document.Print()
-
End If
-
End Sub
-
Private Function PreparePrintDocument() As PrintDocument
-
-
' Make the PrintDocument object.
-
-
Dim print_document As New PrintDocument
-
-
' Install the PrintPage event handler.
-
-
AddHandler print_document.PrintPage, AddressOf Print_PrintPage
-
-
' Return the object.
-
-
Return print_document
-
-
End Function
-
Private Sub Print_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
-
Dim i As Integer = 0
-
Dim j As Integer = 0
-
Dim k As Integer = 70
-
Dim P As Integer = 320
-
-
Dim imagePrint As Image = cd.Image
-
Dim AA As Integer = Integer.Parse(imagePrint.Height.ToString)
-
Dim tableFont As Font = New Font("Georgia", 14, FontStyle.Bold)
-
Dim tableFont1 As Font = New Font("Georgia", 12, FontStyle.Regular)
-
Dim tableFont4 As Font = New Font("Georgia", 11, FontStyle.Regular)
-
Dim tableFont2 As Font = New Font("Times New Roman", 12, FontStyle.Bold)
-
e.Graphics.DrawImage(imagePrint, 40, -70, imagePrint.Width, imagePrint.Height)
-
e.Graphics.DrawString(LblPDV.Text, tableFont, Brushes.Black, 350, 129)
-
e.Graphics.DrawString("NAME OF CLIENT", tableFont2, Brushes.Black, 70, 239)
-
e.Graphics.DrawString("PURPOSE", tableFont2, Brushes.Black, 195, 239)
-
e.Graphics.DrawString("DATE", tableFont2, Brushes.Black, 320, 239)
-
e.Graphics.DrawString("TOTAL AMOUNT ", tableFont2, Brushes.Black, 450, 239)
-
e.Graphics.DrawString("AMOUNT PAID", tableFont2, Brushes.Black, 570, 239)
-
e.Graphics.DrawString("BALANCE", tableFont2, Brushes.Black, 695, 239)
-
-
12: Do Until j = gv.ColumnCount
-
e.Graphics.DrawString(gv.Item(j, i).Value.ToString, tableFont4, Brushes.Black, k, P)
-
k = k + 125
-
j = j + 1
-
Loop
-
k = 70
-
P = P + 40
-
j = 0
-
i = i + 1
-
If i < gv.RowCount Then GoTo 12
-
-
e.HasMorePages = False
-
-
End Sub
-
-
Private Sub pprev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pprev.Click
-
' Make a PrintDocument and attach it to
-
-
' the PrintPreview dialog.
-
-
dlgPrintPreview.Document = PreparePrintDocument()
-
-
' Preview.
-
-
dlgPrintPreview.WindowState = FormWindowState.Maximized
-
-
dlgPrintPreview.ShowDialog()
-
End Sub
0 1553 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: JasmineC |
last post by:
Hi there!
I'm having some problems printing out my windows form. Here's what I need to
do:
I need to print a datagrid off a windows form, however the datagrid is
bigger than screen. When I tried to print the datagrid, it only print
whatever is on the screen and it cut off the rest. I'm not familiar with the
print control at all. Can anyone give me some help??
Thanks in Advance!
Jasmine
|
by: Namratha Shah \(Nasha\) |
last post by:
Hey Guys,
Today we are going to look at Code Access Security.
Code access security is a feature of .NET that manages code depending on its
trust level. If the CLS trusts the code enough to allow it ro run then it
will execute, the code execution depends on the permission provided to the
assembly. If the code is not trusted wnough to run or it attempts to perform
an action which doe not have the required permissions then its execution...
|
by: Allen Davis |
last post by:
I have some hierarchical data bound to a series of nested DataLists and
DataGrids for which I'd like to be able to provide the end-user some
targeted printing capabilities. By that I mean being able to send just one
parent dataitem and all its children to the printer. Does anyone have any
good suggestions for how to do this or where to look for ideas about how to
accomplish it?
Thanks
|
by: NoSf3RaTu |
last post by:
Is there a way to only print out the datagrid in a given web page? That is I
have a datagrid on my web page but I would like to add a button that will
only give me a page with the datagrid to print but nothing else.
Thanks,
|
by: Paolo Pignatelli |
last post by:
I have an aspx code behind page that goes something like this in the HTML
view:
<asp:HyperLink id=HyperLink1 runat="server"
NavigateUrl='<%#"mailto:" &
DataBinder.Eval(Container.DataItem,"StoreEmail") & "&Subject=" &
DataBinder.Eval(Container.DataItem,"ProductName")
....
| |
by: RRKV |
last post by:
Hi
I have a datagrid which contains 4 rows and a checkbox. when the checkbox
is selected and click the print button it should create an .aspx page which
contains all the data and directly goes to the printer. (It should create
this .aspx page in some Temporary folder since client doesn't want to view it
before printing). Another Problem is from the datagrid i will get a value
which should be assigned to the no of copies property of...
|
by: ComputerStop |
last post by:
I am attempting to print a datagridview. I have not found any method
that works successfully. Has any one been successful with this?
|
by: hussaini |
last post by:
please tell me any 1 printing code in datagrid in visual basic 6
in detail -----
Hello seniors members hope u will tell me ..... i have created a form in visual basic 6 so in the form there is a datagrid and a command button so i want to print the records in datagrid when i press that command button it open dailog like ms word CTRL + P its open of printing dailog hope u understand what i meant
|
by: sonicfun2006 |
last post by:
I have SQL Server Database and MS Access 2003 is connected with ODBC. I have very large amount of records in various tables. The database is very dynamic as it changes every minute. I’m trying to have a live MS Access report which would pull data from SQL Server. I’ll try to explain how I’m trying do this:
The Access report should have two parts:
1. Title page report, just like table of contents. It should be listing a particular field of a...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |