Click here to Skip to main content
15,891,981 members
Articles / Programming Languages / C#
Article

FormHeader control

Rate me:
Please Sign up or sign in to vote.
4.29/5 (16 votes)
27 May 20042 min read 63.6K   1.5K   71   11
Custom FormHeader Control

Image 1

Introduction

Almost all nice dialogs contain a white header bar with information about the current dialog etc. The only support in windows for dialog box headers is built into the property pages using Win32. To solve this, I created a few types of form header classes.

Features

  • Font style of the title message and the body message can be changed. The title font style is set to bold by default
  • Either an icon or an image can be displayed on the right side
  • Depending on the derived class used, either a background image can be displayed or a color slide will be used as background

Classes in this assembly

The assembly contains 3 classes:

  • FormHeader
  • ImageFormHeader
  • ColorSlideFormHeader

FormHeader class

The simplest type of form header is the FormHeader class:

Image 2

FormHeader provides a title text, a message text, an icon or an image. The background color is fixed to white.

C#
this.formHeader1.Image = Image.FromFile( "HeaderImage.bmp" );
this.formHeader1.Message = 
  "This one is very simple. Black font on white backgr...";
this.formHeader1.Title = "FormHeader class Demo application";
This is the base class for all form header classes.

ImageFormHeader class

To include an image as a background, the class ImageFormHeader can be used.

Image 3

It is derived from FormHeader.

C#
this.imageFormHeader1.Image = Image.FromFile( "HeaderImage.bmp" );
this.imageFormHeader1.Message = "Here goes the message bla bla bla...";
this.imageFormHeader1.Title = "FormHeader class Demo Application";
this.imageFormHeader1.BackgroundImage = 
  Image.FromFile( "HeaderBackgroundImage.bmp" );
this.imageFormHeader1.BoundrySize = 5;

ColorSlideFormHeader class

Additionally, the ColorSlideFormHeader class provides a color slide background. The color slide start and end color can also be defined.

Image 4

This class is also derived from FormHeader.

C#
this.colorSlideFormHeader1.Color1 = System.Drawing.Color.White;
this.colorSlideFormHeader1.Color2 = 
  System.Drawing.Color.FromArgb(((System.Byte)(255)), 
  ((System.Byte)(255)), ((System.Byte)(170)));
this.colorSlideFormHeader1.Message = 
  "This ColorSlideFormHeader class contains 2 ...";
this.colorSlideFormHeader1.Title = 
  "Welcome to the FormHeader demo application.";

Using the code

Using the control is very straight forward. First add a reference to your .NET project. Then add it to your tool box and drag it to your form. The control automatically docks to the top. All associated properties can be changed through the Visual Studio property window. Download the whole solution which includes the source code and the demo application shown in the screenshots below.

Example Screenshots

Here are some example screenshots made with the interactive demo (also included in the download):

Image 5

Image 6

Image 7

Image 8

Feedback

Send me feedback if you have some additional ideas.

History

  • May, 19. 2004 - Initial Version 1.0

License

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


Written By
Web Developer
Switzerland Switzerland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionLicense? Pin
guidedways19-Mar-08 6:39
guidedways19-Mar-08 6:39 
General"Read only" failure Pin
DenMelton16-Jan-06 4:20
DenMelton16-Jan-06 4:20 
GeneralRe: "Read only" failure Pin
TeeBee30316-Jan-06 20:40
TeeBee30316-Jan-06 20:40 
GeneralRe: "Read only" failure Pin
DenMelton17-Jan-06 4:28
DenMelton17-Jan-06 4:28 
GeneralRe: "Read only" failure Pin
emanlee27-Jan-07 21:21
emanlee27-Jan-07 21:21 
GeneralMissing the Images Pin
Gary Thom28-May-04 0:07
Gary Thom28-May-04 0:07 
GeneralRe: Missing the Images Pin
TeeBee30328-May-04 0:38
TeeBee30328-May-04 0:38 
thx for the hint.
the missing images can be found in the directory: ".\bin\Release"

copy them it to the directory ".\bin\Debug", so the debug version will also run.

sorry about that Frown | :(
GeneralRe: Missing the Images Pin
Gary Thom28-May-04 1:48
Gary Thom28-May-04 1:48 
GeneralLinear Wash Code Pin
NormDroid27-May-04 23:22
professionalNormDroid27-May-04 23:22 
GeneralRe: Linear Wash Code Pin
TeeBee30327-May-04 23:32
TeeBee30327-May-04 23:32 
GeneralRe: Linear Wash Code Pin
NormDroid27-May-04 23:46
professionalNormDroid27-May-04 23:46 

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.