This is a very simple class that inherits the System.Windows.Forms.Label. basically, its background looks just like Outlook 2003's headers with the Luna theme.
I know we should make it so our App follows a system's theme, and can be easily modified to do so, I just like the blue look
Anyway, here is the class:
VB Code:
public class OutlookLikeHeader : Label
{
public OutlookLikeHeader()
{
this.ForeColor = Color.White;
this.Font = new Font("Arial", 14.25f, FontStyle.Bold);
this.AutoSize = false;
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
}
protected override void OnPaint(PaintEventArgs e)
{
using (Brush b = new SolidBrush(this.ForeColor))
{
e.Graphics.DrawString(this.Text, this.Font, b, e.ClipRectangle.X, e.ClipRectangle.Y);
}
}
protected override void OnPaintBackground(PaintEventArgs pevent)
{
this.Height = Convert.ToInt32(pevent.Graphics.MeasureString(this.Text, this.Font).Height)+ 5;
using (Brush b = new LinearGradientBrush(this.ClientRectangle, Color.FromArgb(88, 133, 214), Color.FromArgb(15, 55, 154), LinearGradientMode.Vertical))
{
pevent.Graphics.FillRectangle(b, this.ClientRectangle);
}
}
}
Attached is what it looks like. It's very basic code but I thought it may help someone.