Click here to Skip to main content
13,248,562 members (76,612 online)
Click here to Skip to main content
Add your own
alternative version


34 bookmarked
Posted 9 Dec 2002

Microsoft Outlook Style Headers

, 9 Dec 2002
Rate this:
Please Sign up or sign in to vote.
Creating Panel Effect Label like Outlook
<!-- Article image -->

Sample Image - HeaderLabel.jpg

<!-- Add the rest of your HTML here -->


Have you ever wondered how in C# to get borders onto visual objects; coming from a Delphi background I was very familiar with having visual controls that offered border effects such as "Etched" or "Sunken" amongst many others. Well, the .NET framework does have this functionality, you just have to impliment it yourselves. The following article will show you how I have taken a simple label object, and applied this logic to obtain a component that offers me the standard microsoft look and feel from programs like Outlook.


Ok, so lets just take a look at the code. Firstly, I need some local properties to allow any of this drawing to take place, I add a visual property called BorderLine, and when set to true, the OnPaint will do our desired drawing, also making use of the so far unused Border3DStyle Enumeration. We set up a property of this type and then set it to Etched as default.

private bool borderLine = true;
private Border3DStyle borderLineStyle = Border3DStyle.Etched;

We then offer the functionality assigned to these two new properties, so that when changed either at runtime or in the ide, they trigger all neccessary redrawing to be done.
Description("Set to True to work with BorderLineStyle" + 
    " To create border effect.")
public bool BorderLine {
  get {
    return borderLine;

  set {
    if( value != borderLine ) {
      borderLine = value;

Description("Add a 3D Style border effect")
public Border3DStyle BorderLineStyle {
  get {
    return borderLineStyle;
  set {
    if( value != borderLineStyle) {
      borderLineStyle = value;

Finally, the Invalidate(); will cause the OnPaint event to be called within the control.
protected override void OnPaint(PaintEventArgs pe) 
  if (borderLine) 
        ClientRectangle.Top +1, 
ClientRectangle.Width -1, 
ClientRectangle.Height -1, 


This is the real crux of the whole thing, there is a method called DrawBorder3D that accepts the client area to use, and a Border3DStyle to draw on it.


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
Does anyone actually read this ? ok, if you do, I used to be a general manager of a computer software company, I developed the applications in Delphi C/S (all versions 2,3,4,5,6). I now am a senior developer for a software company, the language of choice being C#. Although I am a beginner, I hope to become more preficiant in this language as the time goes by.

Cheers for reading if in fact you did actually bother.

You may also be interested in...

Comments and Discussions

GeneralAlways include the entire solution, please. Pin
No Email14-Oct-05 12:37
memberNo Email14-Oct-05 12:37 

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
Web01 | 2.8.171114.1 | Last Updated 10 Dec 2002
Article Copyright 2002 by CodeSlinger
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid