2 Attachment(s)
PrintPreviewDialog Control Menu
Hello all, I have another problem with my project. I have create form from where I whant to print content. For that purpose, I have created new Form, which will show Preview page and print. So here are elements:
Form1: have content in datagridview and button for print. Here is code:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form2.Show()
Hide()
End Sub
Form2: Is empty Form with PrintPreviewControl - streched in all Form2. Here is code that I use:
Code:
Public Class Form2
Private Sub Form2_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
Form1.Show()
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim font1 As New Font("arial", 12, FontStyle.Regular)
Dim ce = Form1.DataGridView1.CurrentCell.RowIndex
e.Graphics.DrawString(Form1.DataGridView1.Item(Form1.Opis.HeaderText, ce).Value.ToString, font1, Brushes.Black, 200, 200)
End Sub
End Class
So when you start application, fill datagridview and click Button1 for print it opens Form2:
Attachment 100393
Problem that I have is that I whant to add PrintPreviewDialog Control Menu to Form2 that I have created:
This Control Menu I whant to add to Form2: Attachment 100395
If I use code:
Code:
PrintPreviewDialog1.ShowDialog()
It works, but opens two dialog, where in one dialog is content but, whitout Control Menu, in second dialog si Menu but no content. But this is not what I whant, I only need Control Menu to Form2.
Any Ideas, realy thanks in advance...
Daniel
Re: PrintPreviewDialog Control Menu
Why not call PrintPreviewDialog1.ShowDialog() in the form where the contents you want to print are located? Creating a whole new form just for the PrintPreviewDialog seems unnecessary.
Re: PrintPreviewDialog Control Menu
Quote:
Originally Posted by
dday9
Why not call PrintPreviewDialog1.ShowDialog() in the form where the contents you want to print are located? Creating a whole new form just for the PrintPreviewDialog seems unnecessary.
It was easy way to print content from datagridview. Is there any faster or same way to print content from datagridview...
Re: PrintPreviewDialog Control Menu
Yeah, take a look here on the forums. There are two post in the code bank:
1) Merrion - Post Number 10
2) .Paul.