๐น Kt-Label
Overview
KtLabel is an enhanced label control from the KimTools.WinForms SDK that extends the standard Windows Forms Label with theme-aware color management. This control automatically adapts to light/dark theme changes and provides a simplified, theme-integrated approach to text display in modern Windows Forms applications.
Key Features
Automatic Theme Integration: Responds to system theme changes in real-time
Simplified Color Management: Uses KtColor for consistent theming across your application
Transparent Background: Automatically sets transparent background for seamless UI integration
Parent Color Inheritance: Inherits parent control colors when no explicit color is set
Use Cases
Display static or dynamic text with automatic theme adaptation
Create labels that match your application's color scheme automatically
Build accessible UI elements that respond to system dark/light mode changes
Simplify color management in complex forms with hierarchical color inheritance
Properties
Text
string
""
The text content displayed by the label. Localizable and bindable to settings.
Color
KtColor
KtColor.Empty
The theme-aware color for the label text. Uses KtColor enumeration for automatic theme adaptation. Values are constrained to 0-99 range.
Property Details
Color Property
Accepts
KtColorenumeration values (constrained via modulo 100 operation)When set to
KtColor.Empty, inherits color from parent controlAutomatically updates when system theme changes
See KtColor Documentation for available color values
Events
Note: Standard Label events remain available (Click, TextChanged, etc.)
Essential Features
1. Theme-Aware Rendering
KtLabel automatically subscribes to theme change events and updates its appearance accordingly:
When the system switches between light and dark modes, all KtLabel instances update their colors automatically without requiring code intervention.
2. Intelligent Color Inheritance
The control implements a smart color resolution system:
If
Coloris set to a specificKtColorvalue, use that colorIf
ColorisKtColor.Empty, inherit from parent control'sForeColorFallback to current
ForeColorif no parent is available
3. Transparent Integration
The label automatically sets its background to transparent, ensuring seamless integration with parent containers:
Examples
Basic Usage
Theme-Adaptive Label
Status Indicator Label
Dynamic Color Updates
Localized Content
Container with Multiple Labels
Best Practices
Use KtColor.Empty for inheritance: Allow labels to inherit colors from their container for consistent theming
Leverage theme events: The control handles theme changes automaticallyโno manual intervention needed
Semantic colors: Use appropriate KtColor values (Success, Error, Warning) for status indicators
Dispose properly: When removing labels programmatically, ensure proper disposal to prevent memory leaks
Test both themes: Verify your UI works correctly in both light and dark modes
Last updated
Was this helpful?