HotDog's Blog

Hotdog (Robert Verpalen) about C# and vb.net

vbCity Blogs moved to:
http://cs.vbcity.com/blogs
  Home :: Syndication  :: Login

OctNovember 2009Dec
SMTWTFS
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

Articles

Archives

Topics

CONTACT

Fun but useful linkies

General

VS 2005

Wolfenstein ET

A usercontrol does not have a default borderstyle property. Still creating different sets of borders is very easy in the might .net.

Inside the System.Windows.Forms namespace (which is referenced by default in  a windowsapplication) there's a class named ControlPaint, which has some very interesting static (shared in vb.net) methods. One of those methods is the DrawBorder3D method, which does just that. You have the choice of several borders (defined in the Border3DStyle enumeration).

All you have to do is override the paint event of your custom control (or add a paint event catcher, but when overriding is possible, it's the preferred method) and do some drawing. For example:

protected override void OnPaint(PaintEventArgs e)

{

base.OnPaint (e);

ControlPaint.DrawBorder3D(

e.Graphics,ClientRectangle,Border3DStyle.Raised);

}

 

That's not too bad is it? The ControlPaint class has a lot of other very usefull methods. For example one paints a comboboxbutton. (all button drawing methods use the ButtonState enumaration so all states can be painted). Others a checkbox, a grid, a grabhandle, you name it. Even a way to draw a disabled image windows style.

Have fun exploring :D

posted on Thursday, September 09, 2004 7:53 AM