VB.Net printing problem HELP HELP

Page 1 of 1

1 Replies - 224 Views - Last Post: 27 February 2012 - 10:27 AM Rate Topic: -----

#1 Ozzy18  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 04-October 11

VB.Net printing problem HELP HELP

Posted 27 February 2012 - 10:12 AM

Hello , I need some help with my printing from my data grid.
Basically I can get all the data within the grid present in the "print preview" however they are not within the right columns , and all the data overlaps , making the printout look very messy ! :(

I need to be able to get all the data into their specific columns , e.g all the names under the name column .

This is my code so dar =] ( its rather long , so please bare with me !)



view source
print?
01	PrintDocument1.DefaultPageSettings.Landscape = True
02	 
03	     Dim Myfont As New Font("Courier New", 10, FontStyle.Regular)
04	     Dim MyFontSmall As New Font("Courier New", 8, FontStyle.Regular)
05	     Dim MyFormat As String = "{0,-6}{1,-12}{2,-12}{3,-8}{4,-23}{5,-12}{6,-20}{7,-20}{8,-6}"
06	     Dim LineToprint As String
07	     Dim X, Y, FontHeight As Integer
08	     X = 10
09	     Y = 50
10	     FontHeight = Myfont.GetHeight(e.Graphics)
11	 
12	     e.Graphics.DrawString("List Of all customers", Myfont, Brushes.Black, X, Y)
13	     Y = Y + FontHeight
14	     e.Graphics.DrawString("", Myfont, Brushes.Black, X, Y)
15	     Y = Y + FontHeight
16	     LineToprint = String.Format(MyFormat, "Name", "Last Name", "Address", "Email", "House phone Number", "Mobile", "Size Of pool", "Size Of sattelite", "CustomerID")
17	     e.Graphics.DrawString(LineToprint, Myfont, Brushes.Black, X, Y)
18	     Y = Y + FontHeight
19	     e.Graphics.DrawString("", Myfont, Brushes.Black, X, Y)
20	 
21	 
22	     Dim DtCustomers As New DataTable()
23	     Dim CustomerColumnIndex, CustomerRowIndex, index As Short
24	     DtCustomers = CustomersDs.Tables(0)
25	 
26	     For CustomerColumnIndex = 0 To DtCustomers.Rows.Count - 1
27	         Y = Y + FontHeight
28	         X = 10
29	 
30	         For CustomerRowIndex = 0 To DtCustomers.Columns.Count - 1
31	 
32	             LineToprint = DtCustomers.Rows(CustomerColumnIndex)(CustomerRowIndex).ToString
33	 
34	             e.Graphics.DrawString(LineToprint, MyFontSmall, Brushes.Black, X, Y)
35	 
36	 
37	             X = X + 100
38	 
39	         Next CustomerRowIndex
40	 
41	     Next CustomerColumnIndex

This post has been edited by modi123_1: 27 February 2012 - 10:25 AM
Reason for edit:: please use code tags


Is This A Good Question/Topic? 0
  • +

Replies To: VB.Net printing problem HELP HELP

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9287
  • View blog
  • Posts: 34,811
  • Joined: 12-June 08

Re: VB.Net printing problem HELP HELP

Posted 27 February 2012 - 10:27 AM

Do not open a duplicate topic. You never responded to the first one a few weeks ago.

http://www.dreaminco...oblem-help-help
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1