• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 173
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

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