Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 681025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:26:16+00:00 2026-05-14T01:26:16+00:00

I have successfully implemented printing and print preview for my app using the PrintDocument,

  • 0

I have successfully implemented printing and print preview for my app using the PrintDocument, PrintDialog and PrintPreviewDialog classes of .NET.

However my app uses a toolkit to improve the appearance of the standard .NET controls. There are versions of most .NET controls in the toolkit, but none for the Print controls.

Therefore to ensure that the appearance of these controls matches the rest of the app I am creating a custom PrintPreviewDialog based on a toolkit form and embedding a .NET PrintPrewviewControl in it.

My problem is that the PrintPreviewControl always shows “No pages to display”. I had no trouble getting this to work using the .NET PrintPreviewDialog and cannot see what I am doing wrong.

This is a .NET 2.0 PrintPreviewControl and so I know that I need to call InvalidatePreview() after assigning the PrintDocument. However it does not seem to matter where i place it, the PrintPage event handler never gets called…

    public class PrintEngine
    {
          ...rest of class...

      public PrintEngine()
      {
         m_printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);
      }

      public void PrintPreview()
      {
        //ORIGINAL CODE USING .NET DIALOG WORK OK
        //PrintPreviewDialog dlg1 = new PrintPreviewDialog();
        //dlg1.Document = m_printDoc;
        //PrepareImageForPrinting();
        //dlg1.ShowDialog();

        //CODE USING MY CUSTOM DIALOG DO NOT WORK?
        MyPrintPreviewDialog dlg2 = new MyPrintPreviewDialog();

        dlg2.Document = m_printDoc;

        PrepareImageForPrinting(); //Creates the m_printImage List

        dlg2.ShowDialog();
      }

      private void printDoc_PrintPage(object sender, PrintPageEventArgs e)
      {
        e.Graphics.DrawImage(m_printImages[m_currentPage], new Point(0, 0));

        m_currentPage++;

        e.HasMorePages = m_currentPage < m_pagesHigh;
      }

    }//end PrintEngine class

    public class MyPrintPreviewDialog : KryptonForm
    {
        public PrintDocument Document
        {
            get { return m_printPreviewControl.Document; }
            set
            { 
                m_printPreviewControl.Document = value;
                m_printPreviewControl.InvalidatePreview();
            }
        }

        public MyPrintPreviewDialog()
        {
          InitializeComponent();

          m_printPreviewControl = new PrintPreviewControl();

          m_printPreviewControl.StartPage = 0;
        }

        private void MyPrintPreviewDialog_Load(object sender, EventArgs e)
        {
          m_printPreviewControl.Document.DefaultPageSettings = new PageSettings();
          m_printPreviewControl.Document.PrinterSettings = new PrinterSettings();

          m_printPreviewControl.InvalidatePreview();
        }

    }//end MyPrintPreviewDialog class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:26:16+00:00Added an answer on May 14, 2026 at 1:26 am

    I’m a bit puzzled by this line:

      m_printPreviewControl = new PrintPreviewControl();
    

    You don’t seem to attach or position this control.

    If you placed it with the Designer, this line should be removed, and you should use the name of the designtime control everywhere..

    If you want to create it manually, you need atr least something like this.Controls.Add(m_printPreviewControl );

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 330k
  • Answers 330k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You shouldn't catch an exception unless you can handle it… May 14, 2026 at 2:33 am
  • Editorial Team
    Editorial Team added an answer It depends on how much your code differs between the… May 14, 2026 at 2:33 am
  • Editorial Team
    Editorial Team added an answer try This This is more prominent solution rather switching to… May 14, 2026 at 2:33 am

Related Questions

We currently have check printing fully implemented and in the field for a POS
Okay, so basically I want to be able to retrieve keyboard text. Like entering
I have successfully implemented interop beftween Win32 application and managed .Net dll as described
I have successfully implemented Forms Authentication in SSRS, so it now uses both Roles
I'm just learning Qt with C++. I have successfully implemented signals and slots to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.