I need to draw an image on a panel, containing some child controls. I dont want to let it hide behind those controls, which is the case right now when m drawing the image on paint event. Please suggest something to overcome this prob.
Here is the code I used to override the OnPaint method of my panel:
protected override void OnPaint(PaintEventArgs e)
{
try
{
base.OnPaint(e);
//Draw icon for views at top right corner of the panel.
e.Graphics.SmoothingMode =
System.Drawing.Drawing2D.SmoothingMode.HighQuality;
if (_viewButton != ViewButton.None)
{
Brush menuBrush =
new SolidBrush(_viewButton == ViewButton.Highlighted ?
Color.Black : Color.Gray);
e.Graphics.FillPolygon(menuBrush, new Point[] {
new Point(this.Width - 29, 03),
new Point(this.Width - 19, 03),
new Point(this.Width - 24, 09) });
menuBrush.Dispose();
//Draw border of the panel.
Rectangle borderRect =
new Rectangle(0, 0, this.Width - 1, this.Height - 1);
GraphicsPath borderPath = GetRoundPath(borderRect, 8);
e.Graphics.DrawPath(new Pen(Color.LightGray), borderPath);
}
}
catch (Exception ex)
{
throw new IDSException(ex);
}
}