old Hippy
Gebruiker
- Lid geworden
- 24 mei 2008
- Berichten
- 911
Hi Allemaal een happy 2009
ik heb een datagritview die ik uit print.
dit gaat goed maar hij print niet de colomnaam mee
Ik wil graag dat hij de colomnamen mee print
dit is de code die ik gebruik.
Weet iemand hoe ik dit kan doen????????
ik heb een datagritview die ik uit print.
dit gaat goed maar hij print niet de colomnaam mee
Ik wil graag dat hij de colomnamen mee print
dit is de code die ik gebruik.
Code:
Private mRow As Integer
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
With OverzichtDataGridView
Dim fmt As StringFormat = New StringFormat(StringFormatFlags.LineLimit)
fmt.LineAlignment = StringAlignment.Center
fmt.Trimming = StringTrimming.EllipsisCharacter
Dim y As Single = e.MarginBounds.Top
Do While mRow < .RowCount
Dim row As DataGridViewRow = .Rows(mRow)
Dim x As Single = e.MarginBounds.Left
Dim h As Single = 0
For Each cell As DataGridViewCell In row.Cells
Dim rc As RectangleF = New RectangleF(x, y, cell.Size.Width, cell.Size.Height)
e.Graphics.DrawRectangle(Pens.Black, rc.Left, rc.Top, rc.Width, rc.Height)
e.Graphics.DrawString(cell.FormattedValue.ToString(), .Font, Brushes.Black, rc, fmt)
x += rc.Width
h = Math.Max(h, rc.Height)
Next
y += h
mRow += 1
If y + h > e.MarginBounds.Bottom Then
e.HasMorePages = True
Exit Sub
End If
Loop
mRow = 0
End With
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
With PageSetupDialog1
.PageSettings = PrintDocument1.DefaultPageSettings
End With
Try
If PageSetupDialog1.ShowDialog = DialogResult.OK Then
PrintDocument1.DefaultPageSettings = PageSetupDialog1.PageSettings
End If
Catch es As Exception
MessageBox.Show(es.Message)
End Try
PrintPreviewDialog1.ShowDialog()
End Sub
Weet iemand hoe ik dit kan doen????????
