 |
|
 |
honey0 Level: Protégé
 Registered: 16-03-2006 Posts: 8
|
Printing datagrid
hey, got plenty of help from here before hoping u can help me with printing a datagrid
at the top of the page im prinitng contains simple data from a few text boxes, but under it i would like to print a datagrid. im am trying to achive a sort of receipt, that contains customer information at the the top and items orderd at the bottom, these items are already in the datagrid
i would like the most simple way of doing this but yet keepin it layed out nicely.
ive seen examples like
Private Sub PrintGrid_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles PrintGrid.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 myPaintArgs As New PaintEventArgs(e.Graphics, New Rectangle(New _
Point(0, 0), Me.Size))
Me.InvokePaint(DataGrid1, myPaintArgs)
End Sub
it didnt work for me, not sure wat printerdoc1 was or wat else i needed to change.
so far im using simple print comds in vb like so
Private Sub Command82_Click()
Printer.FontSize = 18
Printer.FontBold = True
Printer.Print "TITLE"
Printer.Print Text1.Text
.....
.....
now i want it to print datagrid
printer.enddoc
thanks
[Edited by honey0 on 29-03-2006 at 11:11 PM GMT]
|
|
29-03-2006 at 10:59 PM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1652
|
Re: Printing datagrid
I am using CR for the printing purpose, so I will try to help theoretically. This datagrid is most probably bound to DataTable, just loop through all rows, and print them one by one....
Also, look at this article
http://www.codeproject.com/vb/net/DataGrid_Printing_Class.asp
[Edited by Goran on 31-03-2006 at 12:05 AM GMT]
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
30-03-2006 at 10:22 PM |
|
|
honey0 Level: Protégé
 Registered: 16-03-2006 Posts: 8
|
Re: Printing datagrid
thanks goran i did have a look at that link u posted but it seemed so complicated, when u say print them line by line, would that jus be sumthing like
the datagrid is connected to a adodc control
do
printer.print datagrid1.text
datagrid1.moevnext
loop until end of file
or would i have to actually pick out everything like
printer.print adodc1.recordset.fields(0), adodc1.recordset.fields(1), adodc1.recordset.fields(2)
adodc1.recordset.movenext
loop until end of file
is there a cmd for a print preview. and how good is crystal reports, i need sumthing that can be printed off from one button, not go into alot of stuff.
[Edited by honey0 on 30-03-2006 at 11:28 PM GMT]
|
|
|
30-03-2006 at 11:27 PM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1652
|
Re: Printing datagrid
The 2nd one, aktough I dont see the reason why are you sing ADO in .NET since there is ADO.NET> there are much more layers (overheat) involved when using COM objects, instead of framework (data) classes.
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
31-03-2006 at 09:52 AM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1652
|
Re: Printing datagrid
ADO is superseeded with ADO.NET in .NET development. ADO.NET is recommended tool for accessing databases, like SQL server, MS Access, etc...
Using ADO object in .NET is done through Runtime Callable Wrapper (RCW), which handles COM interoperability in .NET. So basically, every value that comes/goes from ADO object is marshalled by RCW object, which causes an unecessary performance overhead.
In short, for regular data access, you should always use ADO.NET, and ADO should be used only in those situations which ADO.NET cant handle properly.
Since you didnt hear about ADO.NET, dont think it is the same as ADO, there isnt much simlarity with them.
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
31-03-2006 at 08:48 PM |
|
|
Merrion Level: VB Guru
 Registered: 15-04-2002 Posts: 37
|
Re: Printing datagrid
I have just posted a class to the downloads area to print the data grid like the excel print system..
____________________________
--8<------------------------------
Free components and source code - see http://www.merrioncomputing.com/Download/index.htm for details
|
|
06-04-2006 at 08:38 PM |
|
|
|
|
 |
 |