Closed Thread
Results 1 to 4 of 4

Thread: Demonstrate PrintPreviewDialog?

  1. #1
    Psynic's Avatar
    Psynic is offline Learning Programmer
    Join Date
    May 2009
    Location
    Canada, AB
    Posts
    61
    Blog Entries
    1
    Rep Power
    11

    Demonstrate PrintPreviewDialog?

    Hi guys, i was wondering if anyone could demonstrate the proper way to use PrintPreviewDialog. the goal in this situation is to simply open the print preview form to print what is in my main textbox for a notepad application. I have checked out the tutorial on the site for making a notepad

    Code:
    //Declare preview as a new PrintPreviewDialog
    PrintPreviewDialog preview = new PrintPreviewDialog();
    //Declare prntDoc_PrintPage as a new EventHandler for prntDoc's Print Page
    prntDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(prntDoc_PrintPage);
    //Set the PrintPreview's Document equal to prntDoc
    preview.Document = prntDoc;
    //Show the PrintPreview Dialog
    if (preview.ShowDialog(this) == DialogResult.OK)
    {
    //Generate the PrintPreview
    prntDoc.Print();
    }
    I get an error on this line of the tutorial
    Code:
    prntDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(prntDoc_PrintPage);
    It says that prntDoc_PrintPage doesnt exsist in the current context even if i add
    Code:
    System.Drawing.Printing.PrintDocument prntDoc = new System.Drawing.Printing.PrintDocument();
    to the beginning. any ideas? +rep as always

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    Nov 2009
    Location
    I seem to be lost...
    Posts
    1,566
    Blog Entries
    1
    Rep Power
    22

    Re: Demonstrate PrintPreviewDialog?

    I don't know whats giving you the error I get it to, but I searched up and down Google and can't find a way to print preview a textboxs text. What you might have to do is save the textbox.text as a temporary document then print preview that but I'm not sure.
    Knowledge: Intermediate C#, Beginner AS3, HTML, CSS, Binary, Hex, Octal.
    Science is only an educated theory, which we cannot disprove.

  4. #3
    Psynic's Avatar
    Psynic is offline Learning Programmer
    Join Date
    May 2009
    Location
    Canada, AB
    Posts
    61
    Blog Entries
    1
    Rep Power
    11

    Re: Demonstrate PrintPreviewDialog?

    Does anyone know how printpreviewdialog could be used in this situation? im dying without this i have been searching for soo long and havent found anything that is working.

  5. #4
    Psynic's Avatar
    Psynic is offline Learning Programmer
    Join Date
    May 2009
    Location
    Canada, AB
    Posts
    61
    Blog Entries
    1
    Rep Power
    11

    Re: Demonstrate PrintPreviewDialog?

    k! i figured some of it out..
    Code:
                PrintDocument prntDoc = new PrintDocument();
                PrintPreviewDialog pDialog = new PrintPreviewDialog();
                pDialog.Show();
    opens the print preview dialog but i cant figure out how to get it to import the text in richTextBox1 to the printpreview form.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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