Solved

How to draw shapes on a tab control

Posted on 2009-04-04
1
1,207 Views
Last Modified: 2013-12-17
Hi,

I have a polygon displayed on the main form in C# using gdi+. This displays fine, but I now need to have more than one polygon displayed, so I need to have each one on a different tab so the user can swap between each one easily. But I have not been able to display gdi graphics on a tab control in C# 2008.

Anyone know more about this? Help much appreciated.
0
Comment
Question by:dg_dibs
1 Comment
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 24068272
Just handle the Paint() event for each TabPage...
    public partial class Form1 : Form
    {
 
        private Point[] poly1 = new Point[] {new Point(50,50), new Point(250,50), new Point(175, 250)};
        private Point[] poly2 = new Point[] { new Point(50, 250), new Point(175, 50), new Point(250, 250) };
 
        private void tabPage1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.DrawPolygon(Pens.Black, poly1);
        }
 
        private void tabPage2_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.DrawPolygon(Pens.Black, poly2);
        }
    }

Open in new window

0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question