Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / December 2005

Tip: Looking for answers? Try searching our database.

Borders for panels possible?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Showjumper - 30 Dec 2005 14:31 GMT

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 - 30 Dec 2005 16:55 GMT
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.compactframewor
k/msg/9716222d161a6e52?hl=en


Signature

Tim Wilson
.NET Compact Framework MVP

> 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?
Simon Hart - 30 Dec 2005 18:22 GMT
Or subclassing and drawing the border yourself using GDI.

Cheers
Simon.

> There are a couple of ways to achieve this...
>
[quoted text clipped - 11 lines]
> could
>> just use styles. Anything for panels in winforms?
Alex Yakhnin [MVP] - 30 Dec 2005 21:39 GMT
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

> Or subclassing and drawing the border yourself using GDI.
>
[quoted text clipped - 16 lines]
> > could
> >> just use styles. Anything for panels in winforms?
Showjumper - 30 Dec 2005 21:59 GMT

Thanks to everyone for the ideas
> Or just hook up into Paint event of a Panel and draw the border. Something
> like that:
[quoted text clipped - 34 lines]
>> > could
>> >> just use styles. Anything for panels in winforms?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.