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 / Windows Forms / WinForm General / May 2006

Tip: Looking for answers? Try searching our database.

UserControl Border Color

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Craig - 25 May 2006 23:04 GMT
Hi

I have a simple UserControl hosting a couple of other controls, the
BorderStyle = BorderStyle.FixedSingle.  All I want to do is change the border
color of the control.

Anyhow got an example on the best approach to do this.  I tried the
following which didn't make any difference:

protected override void OnPaint(PaintEventArgs e) {
 base.OnPaint(e);
 ControlPaint.dr(e.Graphics,
 e.ClipRectangle,
 SystemColors.Desktop,
 ButtonBorderStyle.Solid);
}

Craig
Tim Wilson - 26 May 2006 01:13 GMT
Try setting the BorderStyle to "None" and then something like this...

protected override void OnPaint(PaintEventArgs e)
{
 ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle, Color.Green,
ButtonBorderStyle.Solid);
 base.OnPaint(e);
}

Signature

Tim Wilson
.NET Compact Framework MVP

> Hi
>
[quoted text clipped - 15 lines]
>
> Craig
Craig - 26 May 2006 12:53 GMT
Hi Tim

Thanks for the reply, your suggestion worked a treat!

I have a follow-on question.  Basically same scenario, but instead of being
a UserControl, I would like to chnage the color of the border of a
SplitContainer control.

Your UserControl suggestion unfortunately doesn't work on a SpiltContainer
control :(

Craig

> Try setting the BorderStyle to "None" and then something like this...
>
[quoted text clipped - 24 lines]
> >
> > Craig
Tim Wilson - 26 May 2006 16:35 GMT
Because the SplitContainer is a control that is composed of other controls
that are docked within it (obscuring its client area in which you want to
paint), one easy way to achieve the appearance of a custom border is to
place the SplitContainer inside another Panel and then resize the
SplitContainer to be slightly smaller than the Panel. Now set the BackColor
of the Panel to the color that should be used for the border. The last step
would be to set the Anchor property for the SplitContainer to be all four
sides (Top, Bottom, Left, Right) - this will ensure that if the Panel is
resized the SplitContainer will be resized appropriately. So the outer Panel
is being used as a custom border.

Signature

Tim Wilson
.NET Compact Framework MVP

> Hi Tim
>
[quoted text clipped - 38 lines]
>> >
>> > Craig

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.