I\'m drawing up a day schedule and representing timeslots with panels, and appointments are yet more panels on top.
The user is able to scroll up and down so that th
You need to call this method from the paint event handler, not just whenever you like. So in your constructor you might have:
panel1.Paint += new PaintEventHandler(panel1_Paint);
and then the implementation:
private void panel1_Paint( object sender, PaintEventArgs e )
{
var p = sender as Panel;
var g = e.Graphics;
g.FillRectangle( new SolidBrush( Color.FromArgb( 0, Color.Black ) ), p.DisplayRectangle );
Point[] points = new Point[4];
points[0] = new Point( 0, 0 );
points[1] = new Point( 0, p.Height );
points[2] = new Point( p.Width, p.Height);
points[3] = new Point( p.Width, 0 );
Brush brush = new SolidBrush( Color.DarkGreen );
g.FillPolygon( brush, points );
}