KryptonToolStripContainer Developer Documentation
Overview
KryptonToolStripContainer is a Krypton-themed wrapper for the standard WinForms ToolStripContainer control. It provides full Krypton palette integration, allowing the ContentPanel to be themed consistently with the rest of your Krypton application.
Key Features
- Full Krypton Theming: The
ContentPanelis automatically themed using Krypton palette colors - Palette Support: Supports
PaletteModeand customPaletteproperties - State Management: Provides
StateCommon,StateDisabled, andStateNormalproperties for fine-grained appearance control - Global Palette Integration: Automatically responds to global palette changes
- Standard ToolStripContainer Features: Inherits all functionality from the standard
ToolStripContainer
Namespace
using Krypton.Toolkit;
Class Declaration
public class KryptonToolStripContainer : ToolStripContainer
Properties
Palette Properties
PaletteMode
[Category("Visuals")]
[Description("Sets the palette mode.")]
[DefaultValue(PaletteMode.Global)]
public PaletteMode PaletteMode { get; set; }
Gets or sets the palette mode. Valid values:
PaletteMode.Global(default) - Uses the global palette fromKryptonManagerPaletteMode.ProfessionalSystem- Uses the Professional System palettePaletteMode.ProfessionalOffice2003- Uses the Office 2003 palettePaletteMode.Office2007Blue,Office2007Silver,Office2007Black- Office 2007 palettesPaletteMode.Office2010Blue,Office2010Silver,Office2010Black,Office2010White- Office 2010 palettesPaletteMode.Office2013- Office 2013 palettePaletteMode.Microsoft365Dark,Microsoft365Light- Microsoft 365 palettesPaletteMode.SparkleBlue,SparkleOrange,SparklePurple- Sparkle palettesPaletteMode.Custom- Uses a custom palette (requiresPaletteproperty to be set)
Palette
[Category("Visuals")]
[Description("Sets the custom palette to be used.")]
[DefaultValue(null)]
public PaletteBase? Palette { get; set; }
Gets or sets a custom palette implementation. When set, PaletteMode automatically changes to PaletteMode.Custom. Setting to null reverts to PaletteMode.Global.
State Properties
StateCommon
[Category("Visuals")]
[Description("Overrides for defining common appearance that other states can override.")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public PaletteBack StateCommon { get; }
Gets access to the common appearance settings that other states can override. This is the base state from which StateDisabled and StateNormal inherit.
Sub-properties:
StateCommon.Back- Background appearance settingsBack.Color1,Back.Color2- Background colorsBack.ColorStyle- Color style (Solid, Linear, etc.)Back.ColorAlign- Color alignmentBack.ColorAngle- Gradient angleBack.Image- Background imageBack.ImageStyle- Image styleBack.ImageAlign- Image alignment
StateDisabled
[Category("Visuals")]
[Description("Overrides for defining disabled appearance.")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public PaletteBack StateDisabled { get; }
Gets access to the disabled state appearance settings. Used when the control is disabled.
StateNormal
[Category("Visuals")]
[Description("Overrides for defining normal appearance.")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public PaletteBack StateNormal { get; }
Gets access to the normal state appearance settings. Used when the control is enabled and in normal state.
Inherited Properties
KryptonToolStripContainer inherits all properties from ToolStripContainer, including:
ContentPanel- The main content panel that can be themedTopToolStripPanel,BottomToolStripPanel,LeftToolStripPanel,RightToolStripPanel- Tool strip panelsDock- Docking behaviorEnabled- Control enabled state- All standard
Controlproperties
Methods
SetFixedState
public virtual void SetFixedState(PaletteState state)
Fixes the control to a particular palette state. This method is provided for API consistency with other Krypton controls but is not typically used for ToolStripContainer.
Parameters:
state- The palette state to fix (Normal, Disabled, etc.)
Events
KryptonToolStripContainer inherits all events from ToolStripContainer and Control, including:
Paint- Raised when the control is paintedEnabledChanged- Raised when theEnabledproperty changes- Standard control events
Usage Examples
Basic Usage
// Create a KryptonToolStripContainer
var container = new KryptonToolStripContainer
{
Dock = DockStyle.Fill
};
// Add tool strips to the panels
var menuStrip = new KryptonMenuStrip();
container.TopToolStripPanel.Controls.Add(menuStrip);
var toolStrip = new KryptonToolStrip();
container.TopToolStripPanel.Controls.Add(toolStrip);
var statusStrip = new KryptonStatusStrip();
container.BottomToolStripPanel.Controls.Add(statusStrip);
// Add content to the content panel
var panel = new KryptonPanel { Dock = DockStyle.Fill };
container.ContentPanel.Controls.Add(panel);
Custom Palette Mode
// Use a specific built-in palette
var container = new KryptonToolStripContainer
{
PaletteMode = PaletteMode.Office2013,
Dock = DockStyle.Fill
};
Custom Palette
// Create and use a custom palette
var customPalette = new KryptonCustomPalette();
// ... configure custom palette ...
var container = new KryptonToolStripContainer
{
Palette = customPalette,
Dock = DockStyle.Fill
};
Customizing Appearance
var container = new KryptonToolStripContainer();
// Customize the common state background
container.StateCommon.Back.Color1 = Color.LightBlue;
container.StateCommon.Back.Color2 = Color.White;
container.StateCommon.Back.ColorStyle = PaletteColorStyle.Linear;
// Customize the normal state (overrides common)
container.StateNormal.Back.Color1 = Color.LightGray;
// Customize the disabled state
container.StateDisabled.Back.Color1 = Color.Gray;
Responding to Global Palette Changes
// The control automatically responds to global palette changes
// when PaletteMode is set to Global (default)
// Change the global palette
KryptonManager.GlobalPalette = new PaletteOffice2013();
// All KryptonToolStripContainer instances with PaletteMode.Global
// will automatically update their appearance
Best Practices
Use Global Palette for Consistency: Unless you need per-control theming, use
PaletteMode.Global(the default) to ensure consistency across your application.ContentPanel Theming: The
ContentPanelis automatically themed. If you need additional theming, add aKryptonPanelto theContentPanel.State Customization: Use
StateCommonfor shared settings, and override withStateNormalorStateDisabledonly when necessary.Disposal: The control properly disposes of palette resources. Ensure proper disposal when removing from forms.
Performance: The control uses efficient palette redirection. Avoid creating unnecessary custom palettes for simple color changes; use state properties instead.
Integration with Other Controls
KryptonToolStripContainer works seamlessly with:
KryptonMenuStrip- Add toTopToolStripPanelKryptonToolStrip- Add to any tool strip panelKryptonStatusStrip- Add toBottomToolStripPanelKryptonPanel- Add toContentPanelfor additional theming- All standard WinForms controls
Technical Details
Palette Architecture
The control uses the Krypton palette system:
- PaletteRedirect: Redirects palette requests to the current palette
- PaletteDoubleRedirect: Manages background and border styles
- PaletteDouble: Provides state-specific overrides
ContentPanel Painting
The ContentPanel is a standard Panel control. The theming is applied by:
- Hooking into the
ContentPanel.Paintevent - Querying the palette for background colors based on the current state
- Drawing the background using
Graphics.FillRectanglewith palette colors
State Management
- Common State: Base settings shared by all states
- Normal State: Used when the control is enabled
- Disabled State: Used when the control is disabled
States inherit from each other in this order: StateDisabled/StateNormal → StateCommon → Palette.
See Also
KryptonPanel- For additional panel themingKryptonMenuStrip- Menu strip controlKryptonToolStrip- Tool strip controlKryptonStatusStrip- Status strip controlPaletteMode- Enumeration of available palette modesPaletteBase- Base class for custom palettes