Results 1 to 4 of 4

Thread: PrintPreviewDialog Control Menu

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2013
    Posts
    120

    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:

    Name:  Form2.JPG
Views: 660
Size:  17.0 KB

    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:
    Name:  Control1.JPG
Views: 645
Size:  11.0 KB

    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

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,381

    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.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2013
    Posts
    120

    Re: PrintPreviewDialog Control Menu

    Quote Originally Posted by dday9 View Post
    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...

  4. #4
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,381

    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.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width