How to change the borderColor for a panel control

S

sajin

Hi,

I am using VB .net 2005 to create my windows form application , i have
a panel control in my main form , i want to change the border color of
the panel to red color , could any one help me to resolve this problem

Thanks in advance
Sajin
 
T

Tim Wilson

You can set the BorderStyle of the Panel to None, and then add an event
handler for the Paint event and draw a border in whatever color, thickness,
or pattern that you'd like.
 
G

Geoff Munday

Derive a custom control from a Panel and add the following code to
"paint" the red border.

protected override void OnPaint(PaintEventArgs pe)
{
// TODO: Add custom paint code here
pe.Graphics.DrawRectangle(Pens.Red,
pe.ClipRectangle.Left,
pe.ClipRectangle.Top,
pe.ClipRectangle.Width - 1,
pe.ClipRectangle.Height - 1);

// Calling the base class OnPaint
base.OnPaint(pe);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top