€ teken in print preview

Status
Niet open voor verdere reacties.

mustangBE

Gebruiker
Lid geworden
2 jun 2007
Berichten
349
ik heb een datagrid view met gegevens en pijzen die ik wil afdrukken.
in de view wordt alles goed weergegevens maar in de printpreview wordt dit niet weergegeven.

iemand een idee ???

Code:
Public Sub DocToPrint_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles DocToPrint.BeginPrint 
oStringFormat = New StringFormat 
oStringFormat.Alignment = StringAlignment.Near 
oStringFormat.LineAlignment = StringAlignment.Center 
oStringFormat.Trimming = StringTrimming.EllipsisCharacter 
oStringFormatComboBox = New StringFormat 
oStringFormatComboBox.LineAlignment = StringAlignment.Center 
oStringFormatComboBox.FormatFlags = StringFormatFlags.NoWrap 
oStringFormatComboBox.Trimming = StringTrimming.EllipsisCharacter 
oButton = New Button 
oCheckbox = New CheckBox 
oComboBox = New ComboBox 
nTotalWidth = 0 
For Each oColumn As DataGridViewColumn In DataGridView1.Columns 
If oColumn.Visible = True Then ' Prints only Visible columns 
nTotalWidth += oColumn.Width 
End If 
Next 
nPageNo = 1 
NewPage = True 
nRowPos = 0 

End Sub 
Public Sub DocToPrint_EndPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles PrintDocument1.EndPrint 
'Not currently used 
End Sub 

Public Sub DocToPrint_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles DocToPrint.PrintPage 
Header = "Prijslijst " 
Static oColumnLefts As New ArrayList 
Static oColumnWidths As New ArrayList 
Static oColumnTypes As New ArrayList 
Static nHeight As Int16 
Dim nWidth, i, nRowsPerPage As Int16 
Dim nTop As Int16 = e.MarginBounds.Top 
Dim nLeft As Int16 = e.MarginBounds.Left 

If nPageNo = 1 Then 
oColumnLefts.Clear() 
oColumnWidths.Clear() 
oColumnTypes.Clear() 

For Each oColumn As DataGridViewColumn In DataGridView1.Columns 
If oColumn.Visible = True Then ' Prints cols with Visible property 
nWidth = CType(Math.Floor(oColumn.Width / nTotalWidth * nTotalWidth * (e.MarginBounds.Width / nTotalWidth)), Int16) 
nHeight = e.Graphics.MeasureString(oColumn.HeaderText, oColumn.InheritedStyle.Font, nWidth).Height + 11 
oColumnLefts.Add(nLeft) 
oColumnWidths.Add(nWidth) 
oColumnTypes.Add(oColumn.GetType) 
nLeft += nWidth 
End If 
Next 
End If 

Do While nRowPos < DataGridView1.Rows.Count - 1 ' Reports of failing to Print last 
'row. If so remove -1 from above line 
Dim oRow As DataGridViewRow = DataGridView1.Rows(nRowPos) 
If nTop + nHeight >= e.MarginBounds.Height + e.MarginBounds.Top Then 
DrawFooter(e, nRowsPerPage) 
NewPage = True 
nPageNo += 1 
e.HasMorePages = True 
Exit Sub 
Else 
If NewPage Then 
' Draw Header 
e.Graphics.DrawString(Header, New Font(DataGridView1.Font, FontStyle.Bold), Brushes.Black, e.MarginBounds.Left, e.MarginBounds.Top - e.Graphics.MeasureString(Header, New Font(DataGridView1.Font, FontStyle.Bold), e.MarginBounds.Width).Height - 13) 
' Draw Columns 
nTop = e.MarginBounds.Top 
i = 0 
For Each oColumn As DataGridViewColumn In DataGridView1.Columns 
If oColumn.Visible = True Then ' Prints cols with Visible property 
e.Graphics.FillRectangle(New SolidBrush(Drawing.Color.LightGray), New Rectangle(oColumnLefts(i), nTop, oColumnWidths(i), nHeight)) 
e.Graphics.DrawRectangle(Pens.Black, New Rectangle(oColumnLefts(i), nTop, oColumnWidths(i), nHeight)) 
e.Graphics.DrawString(oColumn.HeaderText, oColumn.InheritedStyle.Font, New SolidBrush(oColumn.InheritedStyle.ForeColor), New RectangleF(oColumnLefts(i), nTop, oColumnWidths(i), nHeight), oStringFormat) 
i += 1 
End If 
Next 

NewPage = False 

End If
 
Status
Niet open voor verdere reacties.

Nieuwste berichten

Terug
Bovenaan Onderaan