HI,
I WORK WITH PRINTDOCUMENT CONTROL AND I WANT TO PRINT MORE THAN 1 PAGES. I PUT IN PrintDocument1_PrintPage CODE : - Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
-
-
Dim Lm As Integer
-
Dim Rm, dgvRows As Integer
-
Dim HasMorePages As Boolean = True
-
Static pagenum As Integer
-
With Form9.dgv2
-
Dim fmt As StringFormat = New StringFormat(StringFormatFlags.LineLimit)
-
fmt.LineAlignment = StringAlignment.Center
-
fmt.Trimming = StringTrimming.EllipsisCharacter
-
Dim y As Single = e.MarginBounds.Top 'ΕΧΕΙ ΤΙΜΗ 100
-
newPage = True
-
Do While mRow < Form9.dgv2.RowCount
-
Dim row As DataGridViewRow = Form9.dgv2.Rows(mRow)
-
Dim x As Single = e.MarginBounds.Left - 95
-
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)
-
If (newPage) Then
-
PrintFont = New Font("arial black", 7)
-
e.Graphics.DrawString(Form9.dgv2.Columns(cell.ColumnIndex).HeaderText, PrintFont, Brushes.Black, rc, fmt)
-
Else e.Graphics.DrawString(Form9.dgv2.Rows(cell.RowIndex).Cells(cell.ColumnIndex).FormattedValue.ToString(), Form9.dgv2.Font, Brushes.Black, rc, fmt)
-
End If
-
x += rc.Width
-
h = Math.Max(h, rc.Height)
-
Next
-
newPage = False
-
y += h
-
mRow += 1
-
If y + h > e.MarginBounds.Bottom - 100 Then
-
e.HasMorePages = HasMorePages
-
mRow = mRow - 1
-
Exit Sub
-
End If
-
Loop
-
mRow = 0
-
-
End With
-
-
End Sub ]
-
-
IN CREATING PREVIEWS MESSAGEBOX SHOWS THAT CREATES 2 PAGES. IN THE PRINDOCUMET AREA IN THE SCREEN SHOWS THE 1 PAGE. IN PRINT BUTTON PUT THE CODE :
-
[ Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
-
PrintPreviewDialog1.Document = PrintDocument1
-
PrintPreviewDialog1.ShowDialog()
-
End Sub
BUT WHEN I PUSH PRINT BUTTON PRINTS ME ONLY THE SECOND PAGE.
CAN ANYONE HELP ME ?
THANKS
2 1485
There isn't any built in printing support, so there are two options:
1) Use the standard printing system provided by Windows Forms and manually print out the information that you want. Check out the documentation for PrintPage and PrintDocument
2) Use the DataGridView's clipboard copy support to copy the content to an Excel file and then print that.
Jennypliskin,
Thanks a lot for your help.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Arno Au |
last post by:
Hi,
how can I print the content of a datagridview in vb 2005?
thanks for answers,
Arno
|
by: Marc |
last post by:
Hallo,
can someone tell me, how i could print a datagridview?
I found in the whole net nothing :(
bye
|
by: lcw1964 |
last post by:
This may be in the category of bush-league rudimentary, but I am quite
perplexed on this and diligent Googling has not provided me with a
clear straight answer--perhaps I don't know how to ask the...
|
by: Daniel Manes |
last post by:
I need a strategy to debug this situation...
I can't put all the code involved, but here are some of the critical
lines with comments:
-------------------------
Private _parentDataCell As...
|
by: vanderlej |
last post by:
does anyone have code for PrintPreview and print of DataGridView?
thanks
|
by: murali007 |
last post by:
Hi,
i have to print datagridview content and some text using c# in windows application..
iam able to print datagridview print seperate and text seperate print ..
but iam not able to print both...
|
by: gleave |
last post by:
Hi, below is the code i got to print a datagridview, the trouble is it also prints visible columns which i don't want to be printed. Does anyone have any ideas on how i could change the code so it...
|
by: remya1000 |
last post by:
I’m using VB.Net 2008 application program.
I’m using DataGridView. I have a Print option where i need to print the DataGridView.
I’m using this code for Printing and for Print Preview.
...
|
by: remya1000 |
last post by:
I’m using VB.Net 2008 application program.
I’m using DataGridView. I have a Print Preview option where i need to print the DataGridView.
I’m using this code for Print Preview.
Dim...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |