Click here to Skip to main content
12,758,605 members (33,855 online)
Click here to Skip to main content
Add your own
alternative version


47 bookmarked
Posted 15 Jun 2005

BevelLine Control with Designer Selection Rules

, 15 Jun 2005
Rate this:
Please Sign up or sign in to vote.
A bevel line control with Visual Studio Designer SelectionRule support.

Sample Image - BevelLineScreenshot.gif


I decided to write this bevel line control when I saw that (many moons ago) Visual Studio 2002 didn't have it in its toolbox. Coming from a Visual Basic 6 background, I was disappointed not to have a Shape control (coming in another article) to generate lines for bevels.

Using the code

Here's a sample of all the properties that make a difference:

   bevelLine1.BevelLineWidth = 1;
   bevelLine1.Blend = false;
   bevelLine1.TopLineColor = SystemColors.ControlDark;
   bevelLine1.BottomLineColor = SystemColors.ControlLightLight;
   bevelLine1.Orientation = Orientation.Horizontal;

When using the Form Designer, you can only drag the control width if it is in the horizontal position. To change the control height, set the BevelLineWidth. Using the Blend feature will do a gradient fill rather than a solid one.

Points of Interest

This control stands out from the others because I have implemented a ControlDesigner. This visually guides the developer when selecting the BeveLine control as to whether it can be sized left to right or up and down dependent on the orientation.

This does not work in Visual Studio 2005 Beta 2 as they have modified the selection drawing routine. In previous versions of Visual Studio, it would draw all selection grips around a control at design time but not allow the developer to alter the disabled option. However in Visual Studio 2005 Beta 2, it will not draw the disabled SelectionRules, and if the height of the control is less than 18 it will not be shown!

Using the Designer attribute allows us to reference the designer from the control.

 public class BevelLine : System.Windows.Forms.Control
    // code...

This is the designer code for the BevelLine. It inherits from ControlDesigner which you have to add the reference System.Design to be able to use in your project.

Overriding the SelectionRules allows you to set selection grips, whether the developer can move it at design time, and whether it's visible. You can actually reference the actual control at design time by using the base.Control property and casting it to your control.

public class BevelLineDesigner : System.Windows.Forms.Design.ControlDesigner
  public BevelLineDesigner()
  public override SelectionRules SelectionRules
    SelectionRules rules; 
    rules = base.SelectionRules;
    // If using 2005 Beta 2 then comment this code to have
    // selective grip handles on the BevelLine control in the Designer
    if (((BevelLine)base.Control).Orientation == 
        rules = SelectionRules.Moveable | SelectionRules.Visible
            | SelectionRules.LeftSizeable | SelectionRules.RightSizeable;
        rules = SelectionRules.Moveable | SelectionRules.Visible
            | SelectionRules.TopSizeable | SelectionRules.BottomSizeable;
    return rules;


  • Uploaded as Visual Studio 2005 Beta 2 solution - 16 June 2005.
  • Uploaded as Visual Studio 2003 solution - 16 June 2005.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
United Kingdom United Kingdom
No Biography provided

You may also be interested in...


Comments and Discussions

QuestionText Pin
denson22-May-07 10:01
memberdenson22-May-07 10:01 
GeneralThank you Pin
Martin Lundberg23-Nov-05 20:38
memberMartin Lundberg23-Nov-05 20:38 
GeneralSimpler way Pin
ov14-Oct-05 5:33
memberov14-Oct-05 5:33 
GeneralRe: Simpler way Pin
Lubos Hasko30-Oct-05 18:08
memberLubos Hasko30-Oct-05 18:08 
GeneralRe: Simpler way Pin
ov30-Oct-05 20:00
memberov30-Oct-05 20:00 
GeneralRe: Simpler way Pin
Lubos Hasko31-Oct-05 12:03
memberLubos Hasko31-Oct-05 12:03 
GeneralRe: Simpler way Pin
ov31-Oct-05 20:47
memberov31-Oct-05 20:47 
GeneralRe: Simpler way Pin
Frederic Sivignon25-Apr-06 3:17
memberFrederic Sivignon25-Apr-06 3:17 
GeneralSimpler way (update) Pin
gragramel3-May-06 22:08
membergragramel3-May-06 22:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170217.1 | Last Updated 16 Jun 2005
Article Copyright 2005 by DXNuk
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid