Borders for panels possible?

  • Thread starter Thread starter Showjumper
  • Start date Start date
S

Showjumper

Is it possible to give borders to panels? I am using a panel for an about
screen and i'd like it to have a black border. If this were asp.net i could
just use styles. Anything for panels in winforms?
 
Or just hook up into Paint event of a Panel and draw the border. Something
like that:

panel1.Paint+=new PaintEventHandler(panel1_Paint);

private void panel1_Paint(object sender, PaintEventArgs e)
{
Rectangle rc = new Rectangle(0, 0, panel1.Width - 1, panel1.Height - 1);
e.Graphics.DrawRectangle(new Pen(Color.Black), rc);
}
 
Thanks to everyone for the ideas
Alex Yakhnin said:
Or just hook up into Paint event of a Panel and draw the border. Something
like that:

panel1.Paint+=new PaintEventHandler(panel1_Paint);

private void panel1_Paint(object sender, PaintEventArgs e)
{
Rectangle rc = new Rectangle(0, 0, panel1.Width - 1, panel1.Height -
1);
e.Graphics.DrawRectangle(new Pen(Color.Black), rc);
}
 
Back
Top