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 !)
PrintDocument1.DefaultPageSettings.Landscape = True
Dim Myfont As New Font("Courier New", 10, FontStyle.Regular)
Dim MyFontSmall As New Font("Courier New", 8, FontStyle.Regular)
Dim MyFormat As String = "{0,-6}{1,-12}{2,-12}{3,-8}{4,-23}{5,-12}{6,-20}{7,-20}{8,-6}"
Dim LineToprint As String
Dim X, Y, FontHeight As Integer
X = 10
Y = 50
FontHeight = Myfont.GetHeight(e.Graphics)
e.Graphics.DrawString("List Of all customers", Myfont, Brushes.Black, X, Y)
Y = Y + FontHeight
e.Graphics.DrawString("", Myfont, Brushes.Black, X, Y)
Y = Y + FontHeight
LineToprint = String.Format(MyFormat, "Name", "Last Name", "Address", "Email", "House phone Number", "Mobile", "Size Of pool", "Size Of sattelite", "CustomerID")
e.Graphics.DrawString(LineToprint, Myfont, Brushes.Black, X, Y)
Y = Y + FontHeight
e.Graphics.DrawString("", Myfont, Brushes.Black, X, Y)
Dim DtCustomers As New DataTable()
Dim CustomerColumnIndex, CustomerRowIndex, index As Short
DtCustomers = CustomersDs.Tables(0)
For CustomerColumnIndex = 0 To DtCustomers.Rows.Count - 1
Y = Y + FontHeight
X = 10
For CustomerRowIndex = 0 To DtCustomers.Columns.Count - 1
LineToprint = DtCustomers.Rows(CustomerColumnIndex)(CustomerRowIndex).ToString
e.Graphics.DrawString(LineToprint, MyFontSmall, Brushes.Black, X, Y)
X = X + 100
Next CustomerRowIndex
Next CustomerColumnIndex
This post has been edited by Atli: 03 February 2012 - 03:32 AM
Reason for edit:: Please use [code] tags when posting code.

New Topic/Question
Reply



MultiQuote



|