a·gen·tic a·gil·i·ty

Custom UI colour scheme for Windows Forms .NET

Learn how to customise Windows Forms ToolStrip, MainMenu, and StatusBar colours in .NET by creating a custom ColorTable and applying it with a custom renderer.

Published on
2 minute read
Image
https://nkdagility.com/resources/2vSr2gsP4Rt
Comments
Subscribe

The easyest way to customise you display of your ToolStrip, MainMenu and StatusBar is to use a custom ColorTable.

Just inherit from the ProfessionalColorRenderer and override what you want, with the colors you want:

1   1:  Public Class MortgagesPlcColorTable
1   2:          Inherits ProfessionalColorTable
1   3:   
1   4:          Public Overrides ReadOnly Property ButtonCheckedHighlightBorder() As System.Drawing.Color
1   5:              Get
1   6:                  Return MyBase.ButtonCheckedHighlightBorder
1   7:              End Get
1   8:          End Property
1   9:   
1  10:          Public Overrides ReadOnly Property MenuItemPressedGradientMiddle() As System.Drawing.Color
1  11:              Get
1  12:                  Return Color.FromArgb(91, 91, 91)
1  13:              End Get
1  14:          End Property
1  15:   
1  16:          Public Overrides ReadOnly Property ToolStripContentPanelGradientBegin() As System.Drawing.Color
1  17:              Get
1  18:                  Return Color.FromArgb(80, 80, 80)
1  19:              End Get
1  20:          End Property
1  21:   
1  22:          Public Overrides ReadOnly Property ToolStripContentPanelGradientEnd() As System.Drawing.Color
1  23:              Get
1  24:                  Return Color.WhiteSmoke
1  25:              End Get
1  26:          End Property
1  27:   
1  28:          Public Overrides ReadOnly Property ToolStripDropDownBackground() As System.Drawing.Color
1  29:              Get
1  30:                  Return Color.FromArgb(91, 91, 91)
1  31:              End Get
1  32:          End Property
1  33:   
1  34:          Public Overrides ReadOnly Property ToolStripGradientBegin() As System.Drawing.Color
1  35:              Get
1  36:                  Return Color.FromArgb(80, 80, 80)
1  37:              End Get
1  38:          End Property
1  39:   
1  40:      End Class

Once you have done this, all you need now is to add it to your contols:

1   1:          System.Windows.Forms.ToolStripManager.Renderer = New ToolStripProfessionalRenderer(New MortgagesPlc.Windows.Forms.MortgagesPlcColorTable)

All done! If you have problems you can inherit from the ToolStrip control and change the renderer in the constructor…

Technorati Tags: .NET

Windows
Comments
Subscribe

No related Blog found.

No related videos found.

Connect with Martin Hinshelwood

If you've made it this far, it's worth connecting with our principal consultant and coach, Martin Hinshelwood, for a 30-minute 'ask me anything' call.

Our Happy Clients​

We partner with businesses across diverse industries, including finance, insurance, healthcare, pharmaceuticals, technology, engineering, transportation, hospitality, entertainment, legal, government, and military sectors.​

Illumina Logo

Illumina

Emerson Process Management Logo

Emerson Process Management

Qualco Logo

Qualco

Capita Secure Information Solutions Ltd Logo

Capita Secure Information Solutions Ltd

Hubtel Ghana Logo

Hubtel Ghana

Ericson Logo

Ericson

Flowmaster (a Mentor Graphics Company) Logo

Flowmaster (a Mentor Graphics Company)

NIT A/S

Genus Breeding Ltd Logo

Genus Breeding Ltd

Sage Logo

Sage

Alignment Healthcare Logo

Alignment Healthcare

Kongsberg Maritime Logo

Kongsberg Maritime

Freadom Logo

Freadom

ProgramUtvikling Logo

ProgramUtvikling

MacDonald Humfrey (Automation) Ltd. Logo

MacDonald Humfrey (Automation) Ltd.

Boxit Document Solutions Logo

Boxit Document Solutions

Healthgrades Logo

Healthgrades

YearUp.org Logo

YearUp.org

Department of Work and Pensions (UK) Logo

Department of Work and Pensions (UK)

New Hampshire Supreme Court Logo

New Hampshire Supreme Court

Nottingham County Council Logo

Nottingham County Council

Washington Department of Enterprise Services Logo

Washington Department of Enterprise Services

Ghana Police Service Logo

Ghana Police Service

Washington Department of Transport Logo

Washington Department of Transport

Akaditi Logo

Akaditi

Microsoft Logo

Microsoft

Capita Secure Information Solutions Ltd Logo

Capita Secure Information Solutions Ltd

NIT A/S

Workday Logo

Workday

Jack Links Logo

Jack Links