3 个解决方案
#1
我自己顶
#2
假设 Panel 实例为 panel1 ,注册 Paint 事件,方法为
private void panel1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawRectangle(Pens.Black, new Rectangle(2, 2, panel1.Width - 5, panel1.Height - 5));
}
#3
将panel的borderStyle属性改下就有边框了,边框是黑色的,,如果不想是黑色就照楼上的做,改下颜色
private void panel1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawRectangle(Pens.LightGreen, new Rectangle(2, 2, panel1.Width - 5, panel1.Height - 5));
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawRectangle(Pens.LightGreen, new Rectangle(2, 2, panel1.Width - 5, panel1.Height - 5));
}
#1
我自己顶
#2
假设 Panel 实例为 panel1 ,注册 Paint 事件,方法为
private void panel1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawRectangle(Pens.Black, new Rectangle(2, 2, panel1.Width - 5, panel1.Height - 5));
}
#3
将panel的borderStyle属性改下就有边框了,边框是黑色的,,如果不想是黑色就照楼上的做,改下颜色
private void panel1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawRectangle(Pens.LightGreen, new Rectangle(2, 2, panel1.Width - 5, panel1.Height - 5));
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawRectangle(Pens.LightGreen, new Rectangle(2, 2, panel1.Width - 5, panel1.Height - 5));
}