Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Borders for panels possible?

5 views
Skip to first unread message

Showjumper

unread,
Dec 30, 2005, 9:31:29 AM12/30/05
to

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?

Tim Wilson UNDERSCORE AT PERIOD

unread,
Dec 30, 2005, 11:55:39 AM12/30/05
to
There are a couple of ways to achieve this...

The simplest way to achieve this is to place one Panel inside another Panel,
set the inside Panel to be slightly smaller (by the desired border
thickness), and then set the BackColor of the outside Panel to the desired
border color.

The other way to achieve this is through p/invokes.
http://groups.google.com/group/microsoft.public.dotnet.framework.compactframework/msg/9716222d161a6e52?hl=en

--
Tim Wilson
.NET Compact Framework MVP

"Showjumper" <dfgkjhdf> wrote in message
news:OttZc2UD...@TK2MSFTNGP11.phx.gbl...

Simon Hart

unread,
Dec 30, 2005, 1:22:30 PM12/30/05
to
Or subclassing and drawing the border yourself using GDI.

Cheers
Simon.

"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message
news:eR8PFHWD...@TK2MSFTNGP15.phx.gbl...

Alex Yakhnin [MVP]

unread,
Dec 30, 2005, 4:39:01 PM12/30/05
to
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);
}


--
Alex Yakhnin, .NET CF MVP
www.intelliprog.com | www.opennetcf.org

Showjumper

unread,
Dec 30, 2005, 4:59:32 PM12/30/05
to

Thanks to everyone for the ideas
"Alex Yakhnin [MVP]" <a.ya...@online.att.net> wrote in message
news:7B45DD9C-342C-4963...@microsoft.com...
0 new messages