Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 171
  • Last Modified:

Graphical output on tab pages

How do I create graphical output that will go on a tab page in a Form, instead of on the body of the form? I have a Form which has several tab pages. I am trying to create a program that will draw different graphs to the different tab pages. For example, I want a horizontal line to be displayed on the second tab page ("tabPage2"). How would I modify the following code to specify the second tab page instead of the base Form?

      Graphics* pg = CreateGraphics();
      Pen* pen1 = new Pen(Color::Black, 1.0);

When I tried this code as written, the line appeared to be under the tab pages.
2 Solutions
Open tabPage2 in the form designer, click Properties - Events. Find the Paint event and double-click it. Designer creates Paint handler for this page:

void tabPage2_Paint( Object8 sender, System::Windows::Forms::PaintEventArgs e)
   Graphics* g = e->Graphics;

   // place drawing code here
owner draw the tab control, refer to the following page

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now