syncfusion-winforms-color-picker
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImplementing Color Picker (ColorPickerUIAdv)
实现颜色选择器(ColorPickerUIAdv)
Guide for implementing the Syncfusion ColorPickerUIAdv control in Windows Forms applications.
用于在 Windows Forms 应用中实现 Syncfusion ColorPickerUIAdv 控件的指南。
Overview
概述
The ColorPickerUIAdv control provides a Microsoft Word 2007-style color selection interface for Windows Forms applications. It offers organized color groups (Recent, Standard, Theme), customizable color palettes, multiple visual styles, and an optional "More Colors" dialog for advanced color selection.
Key Features:
- Color Groups: Recent Colors, Standard Colors, Theme Colors
- Custom Groups: Add user-defined color collections
- Visual Styles: Office2007, Office2010, Office2016, Metro
- Color Dialog: "More Colors" button for advanced selection
- Sub-Items: Color variations and tints
- Events: Picked (on selection), ItemSelection (on hover)
- Automatic Color: Configurable default color button
- Runtime Selection: Dynamic color addition via dialog
ColorPickerUIAdv 控件为 Windows Forms 应用提供了 Microsoft Word 2007 风格的颜色选择界面。它支持有序颜色组(最近使用、标准、主题)、可自定义的调色板、多种视觉样式,以及可选的「更多颜色」对话框来实现高级颜色选择。
核心特性:
- 颜色组: 最近使用颜色、标准颜色、主题颜色
- 自定义组: 可添加用户定义的颜色集合
- 视觉样式: Office2007、Office2010、Office2016、Metro
- 颜色对话框: 「更多颜色」按钮用于高级选择
- 子项: 颜色变体与色调
- 事件: Picked(选中时触发)、ItemSelection(悬停时触发)
- 自动颜色: 可配置的默认颜色按钮
- 运行时选择: 可通过对话框动态添加颜色
When to Use This Skill
何时使用本技能
Use this skill when you need to:
- Implement color selection in Windows Forms applications
- Provide Microsoft Word-style color picker interface
- Organize colors into groups (Recent, Standard, Theme, Custom)
- Allow users to select from predefined color palettes
- Support theme-based color selection
- Add color input controls with Office styling
- Implement "More Colors" dialog for advanced selection
- Handle color selection events in desktop applications
- Create custom color collections for specific domains
当你需要实现以下需求时可以使用本技能:
- 在 Windows Forms 应用中实现颜色选择功能
- 提供 Microsoft Word 风格的颜色选择器界面
- 将颜色分组管理(最近使用、标准、主题、自定义)
- 允许用户从预定义调色板中选择颜色
- 支持基于主题的颜色选择
- 添加带有 Office 样式的颜色输入控件
- 实现「更多颜色」对话框用于高级选择
- 处理桌面应用中的颜色选择事件
- 为特定领域创建自定义颜色集合
Component Features Summary
组件特性汇总
| Feature | Description |
|---|---|
| Color Groups | Recent, Standard, Theme, and Custom groups |
| Sub-Items | Color variations/tints for each base color |
| Visual Styles | Office2007, Office2010, Office2016, Metro |
| Events | Picked (selection), ItemSelection (hover) |
| Dialog | "More Colors" option for advanced selection |
| Customization | Item sizing, spacing, headers, borders |
| Runtime | Dynamic color addition via dialog |
| Themes | Office color schemes (Blue, Silver, Black) |
| 特性 | 描述 |
|---|---|
| 颜色组 | 最近使用、标准、主题和自定义组 |
| 子项 | 每个基础颜色的变体/色调 |
| 视觉样式 | Office2007、Office2010、Office2016、Metro |
| 事件 | Picked(选中触发)、ItemSelection(悬停触发) |
| 对话框 | 「更多颜色」选项用于高级选择 |
| 自定义 | 项大小、间距、头部、边框 |
| 运行时 | 可通过对话框动态添加颜色 |
| 主题 | Office 配色方案(蓝色、银色、黑色) |
Documentation and Navigation Guide
文档与导航指南
Getting Started
入门指南
📄 Read: references/getting-started.md
When you need:
When you need:
- Assembly dependencies and NuGet packages
- Adding ColorPickerUIAdv via designer or code
- Namespace imports (Syncfusion.Windows.Forms.Tools)
- Basic color selection with SelectedColor property
- Initial setup and configuration
- Minimal working example
📄 阅读: references/getting-started.md
当你需要:
当你需要:
- 了解程序集依赖和 NuGet 包
- 通过设计器或代码添加 ColorPickerUIAdv
- 导入命名空间(Syncfusion.Windows.Forms.Tools)
- 使用 SelectedColor 属性实现基础颜色选择
- 完成初始设置与配置
- 获取最小可用示例
Color Groups and Organization
颜色组与组织
📄 Read: references/color-groups.md
When you need:
When you need:
- Understanding default groups (Recent, Standard, Theme)
- Creating custom color groups with CustomGroups property
- Adding color items and sub-items to groups
- Using GroupColorItem and ColorItem classes
- Configuring IsSubItemsVisible and SubItemsDepth
- Setting group names and header heights
- Organizing colors by category or theme
📄 阅读: references/color-groups.md
当你需要:
当你需要:
- 理解默认组(最近使用、标准、主题)
- 通过 CustomGroups 属性创建自定义颜色组
- 向组中添加颜色项和子项
- 使用 GroupColorItem 和 ColorItem 类
- 配置 IsSubItemsVisible 和 SubItemsDepth
- 设置组名和头部高度
- 按类别或主题组织颜色
Appearance and Styling
外观与样式
📄 Read: references/appearance-styling.md
When you need:
When you need:
- Applying visual styles (Office2007, Office2010, Office2016, Metro)
- Configuring Office2007 color schemes (Blue, Silver, Black)
- Using custom colors with Managed theme
- ApplyManagedColors method for app-wide theming
- Border styles (Fixed3D, FixedSingle, None)
- BorderStyle and BorderOffset properties
- UseOffice2007Style property configuration
📄 阅读: references/appearance-styling.md
当你需要:
当你需要:
- 应用视觉样式(Office2007、Office2010、Office2016、Metro)
- 配置 Office2007 配色方案(蓝色、银色、黑色)
- 结合 Managed 主题使用自定义颜色
- 使用 ApplyManagedColors 方法实现应用全局主题
- 配置边框样式(Fixed3D、FixedSingle、None)
- 设置 BorderStyle 和 BorderOffset 属性
- 配置 UseOffice2007Style 属性
Events and Runtime Selection
事件与运行时选择
📄 Read: references/events-selection.md
When you need:
When you need:
- Handling Picked event when color is selected
- Using ItemSelection event for hover interactions
- ColorPickedEventArgs and event properties
- Runtime color selection dialog ("More Colors")
- Configuring AutomaticColor property
- ButtonHeight for automatic button sizing
- Event-driven color handling patterns
📄 阅读: references/events-selection.md
当你需要:
当你需要:
- 处理颜色选中时触发的 Picked 事件
- 使用 ItemSelection 事件实现悬停交互
- 了解 ColorPickedEventArgs 和事件属性
- 配置运行时颜色选择对话框(「更多颜色」)
- 配置 AutomaticColor 属性
- 调整自动按钮的 ButtonHeight
- 实现事件驱动的颜色处理模式
Customization and Layout
自定义与布局
📄 Read: references/customization.md
When you need:
When you need:
- Color item sizing with ColorItemSize property
- Horizontal and vertical spacing between items
- HorizontalItemsSpacing and VerticalItemsSpacing
- Header text alignment with TextAlignment
- Font customization for group headers
- Design-time color editing in property grid
- Advanced layout and spacing options
📄 阅读: references/customization.md
当你需要:
当你需要:
- 通过 ColorItemSize 属性设置颜色项大小
- 调整项之间的水平和垂直间距
- 配置 HorizontalItemsSpacing 和 VerticalItemsSpacing
- 通过 TextAlignment 设置头部文本对齐方式
- 自定义组头部的字体
- 在属性网格中实现设计时颜色编辑
- 实现高级布局和间距配置
Quick Start
快速开始
Basic ColorPickerUIAdv Implementation
ColorPickerUIAdv 基础实现
csharp
using System;
using System.Drawing;
using System.Windows.Forms;
using Syncfusion.Windows.Forms.Tools;
public partial class ColorPickerForm : Form
{
private ColorPickerUIAdv colorPickerUIAdv1;
public ColorPickerForm()
{
InitializeComponent();
// Create ColorPickerUIAdv
colorPickerUIAdv1 = new ColorPickerUIAdv();
colorPickerUIAdv1.Size = new Size(200, 180);
colorPickerUIAdv1.Location = new Point(20, 20);
// Set initial selected color
colorPickerUIAdv1.SelectedColor = Color.Blue;
// Apply Office2016 style
colorPickerUIAdv1.Style = ColorPickerUIAdv.visualstyle.Office2016Colorful;
// Handle color selection
colorPickerUIAdv1.Picked += ColorPickerUIAdv1_Picked;
// Add to form
this.Controls.Add(colorPickerUIAdv1);
}
private void ColorPickerUIAdv1_Picked(object sender,
ColorPickerUIAdv.ColorPickedEventArgs args)
{
// Update form background with selected color
this.BackColor = args.Color;
MessageBox.Show($"Selected Color: {args.Color.Name}");
}
}csharp
using System;
using System.Drawing;
using System.Windows.Forms;
using Syncfusion.Windows.Forms.Tools;
public partial class ColorPickerForm : Form
{
private ColorPickerUIAdv colorPickerUIAdv1;
public ColorPickerForm()
{
InitializeComponent();
// Create ColorPickerUIAdv
colorPickerUIAdv1 = new ColorPickerUIAdv();
colorPickerUIAdv1.Size = new Size(200, 180);
colorPickerUIAdv1.Location = new Point(20, 20);
// Set initial selected color
colorPickerUIAdv1.SelectedColor = Color.Blue;
// Apply Office2016 style
colorPickerUIAdv1.Style = ColorPickerUIAdv.visualstyle.Office2016Colorful;
// Handle color selection
colorPickerUIAdv1.Picked += ColorPickerUIAdv1_Picked;
// Add to form
this.Controls.Add(colorPickerUIAdv1);
}
private void ColorPickerUIAdv1_Picked(object sender,
ColorPickerUIAdv.ColorPickedEventArgs args)
{
// Update form background with selected color
this.BackColor = args.Color;
MessageBox.Show($"Selected Color: {args.Color.Name}");
}
}Assembly Requirements
程序集要求
Required Assemblies:
- Syncfusion.Grid.Base
- Syncfusion.Grid.Windows
- Syncfusion.Shared.Base
- Syncfusion.Shared.Windows
- Syncfusion.Tools.Base
- Syncfusion.Tools.Windows
NuGet Package:
powershell
Install-Package Syncfusion.Tools.Windows所需程序集:
- Syncfusion.Grid.Base
- Syncfusion.Grid.Windows
- Syncfusion.Shared.Base
- Syncfusion.Shared.Windows
- Syncfusion.Tools.Base
- Syncfusion.Tools.Windows
NuGet 包:
powershell
Install-Package Syncfusion.Tools.WindowsCommon Patterns
常用模式
Pattern 1: Color Selection with Event Handler
模式1:带事件处理的颜色选择
csharp
// Setup
private void SetupColorPicker()
{
colorPickerUIAdv1.SelectedColor = Color.White;
colorPickerUIAdv1.Picked += OnColorPicked;
}
// Event handler
private void OnColorPicked(object sender, ColorPickerUIAdv.ColorPickedEventArgs e)
{
// Apply color to target control
targetLabel.ForeColor = e.Color;
// Or update drawing operations
currentBrush = new SolidBrush(e.Color);
canvas.Invalidate();
}csharp
// Setup
private void SetupColorPicker()
{
colorPickerUIAdv1.SelectedColor = Color.White;
colorPickerUIAdv1.Picked += OnColorPicked;
}
// Event handler
private void OnColorPicked(object sender, ColorPickerUIAdv.ColorPickedEventArgs e)
{
// Apply color to target control
targetLabel.ForeColor = e.Color;
// Or update drawing operations
currentBrush = new SolidBrush(e.Color);
canvas.Invalidate();
}Pattern 2: Applying Office2016 Theme
模式2:应用 Office2016 主题
csharp
// Office2016 Colorful style
colorPickerUIAdv1.Style = ColorPickerUIAdv.visualstyle.Office2016Colorful;
// Or Office2016 White
colorPickerUIAdv1.Style = ColorPickerUIAdv.visualstyle.Office2016White;
// Or Office2016 Black
colorPickerUIAdv1.Style = ColorPickerUIAdv.visualstyle.Office2016Black;
// Or Office2016 DarkGray
colorPickerUIAdv1.Style = ColorPickerUIAdv.visualstyle.Office2016DarkGray;csharp
// Office2016 Colorful style
colorPickerUIAdv1.Style = ColorPickerUIAdv.visualstyle.Office2016Colorful;
// Or Office2016 White
colorPickerUIAdv1.Style = ColorPickerUIAdv.visualstyle.Office2016White;
// Or Office2016 Black
colorPickerUIAdv1.Style = ColorPickerUIAdv.visualstyle.Office2016Black;
// Or Office2016 DarkGray
colorPickerUIAdv1.Style = ColorPickerUIAdv.visualstyle.Office2016DarkGray;Pattern 3: Creating Custom Color Group
模式3:创建自定义颜色组
csharp
// Create custom color group
ColorUIAdvGroup customGroup = new ColorUIAdvGroup();
customGroup.Name = "Brand Colors";
customGroup.HeaderHeight = 25;
// Create color items
GroupColorItem primaryColor = new GroupColorItem(customGroup, Color.FromArgb(0, 120, 215));
primaryColor.Index = 0;
// Add tint variations as sub-items
primaryColor.SubItems.Add(new ColorItem(primaryColor, Color.FromArgb(204, 228, 247)));
primaryColor.SubItems.Add(new ColorItem(primaryColor, Color.FromArgb(153, 204, 239)));
primaryColor.SubItems.Add(new ColorItem(primaryColor, Color.FromArgb(102, 163, 224)));
// Add to group and control
customGroup.Items.Add(primaryColor);
customGroup.SubItemsDepth = 1;
customGroup.IsSubItemsVisible = true;
colorPickerUIAdv1.CustomGroups.Add(customGroup);csharp
// Create custom color group
ColorUIAdvGroup customGroup = new ColorUIAdvGroup();
customGroup.Name = "Brand Colors";
customGroup.HeaderHeight = 25;
// Create color items
GroupColorItem primaryColor = new GroupColorItem(customGroup, Color.FromArgb(0, 120, 215));
primaryColor.Index = 0;
// Add tint variations as sub-items
primaryColor.SubItems.Add(new ColorItem(primaryColor, Color.FromArgb(204, 228, 247)));
primaryColor.SubItems.Add(new ColorItem(primaryColor, Color.FromArgb(153, 204, 239)));
primaryColor.SubItems.Add(new ColorItem(primaryColor, Color.FromArgb(102, 163, 224)));
// Add to group and control
customGroup.Items.Add(primaryColor);
customGroup.SubItemsDepth = 1;
customGroup.IsSubItemsVisible = true;
colorPickerUIAdv1.CustomGroups.Add(customGroup);Pattern 4: Office2007 Theme with Custom Colors
模式4:带自定义颜色的 Office2007 主题
csharp
// Set Managed theme
colorPickerUIAdv1.UseOffice2007Style = true;
colorPickerUIAdv1.Office2007Theme = Office2007Theme.Managed;
// Apply custom color scheme
Office2007Colors.ApplyManagedColors(this, Color.Teal);csharp
// Set Managed theme
colorPickerUIAdv1.UseOffice2007Style = true;
colorPickerUIAdv1.Office2007Theme = Office2007Theme.Managed;
// Apply custom color scheme
Office2007Colors.ApplyManagedColors(this, Color.Teal);Pattern 5: Hover Preview with ItemSelection Event
模式5:通过 ItemSelection 事件实现悬停预览
csharp
// Setup hover event
colorPickerUIAdv1.ItemSelection += ColorPickerUIAdv1_ItemSelection;
// Event handler for hover preview
private void ColorPickerUIAdv1_ItemSelection(object sender,
ColorPickerUIAdv.ColorPickedEventArgs e)
{
// Show preview without committing
previewPanel.BackColor = e.Color;
statusLabel.Text = $"Preview: {e.Color.Name} (RGB: {e.Color.R}, {e.Color.G}, {e.Color.B})";
}csharp
// Setup hover event
colorPickerUIAdv1.ItemSelection += ColorPickerUIAdv1_ItemSelection;
// Event handler for hover preview
private void ColorPickerUIAdv1_ItemSelection(object sender,
ColorPickerUIAdv.ColorPickedEventArgs e)
{
// Show preview without committing
previewPanel.BackColor = e.Color;
statusLabel.Text = $"Preview: {e.Color.Name} (RGB: {e.Color.R}, {e.Color.G}, {e.Color.B})";
}Pattern 6: Configuring Automatic Color Button
模式6:配置自动颜色按钮
csharp
// Set automatic color (shown when "Automatic" button is clicked)
colorPickerUIAdv1.AutomaticColor = Color.Black;
// Adjust button height
colorPickerUIAdv1.ButtonHeight = 30;csharp
// Set automatic color (shown when "Automatic" button is clicked)
colorPickerUIAdv1.AutomaticColor = Color.Black;
// Adjust button height
colorPickerUIAdv1.ButtonHeight = 30;Key Properties
核心属性
Color Selection
颜色选择
- SelectedColor - Gets/sets the currently selected color
- SelectedItem - Gets the selected color item object
- AutomaticColor - Default color for "Automatic" button
- SelectedColor - 获取/设置当前选中的颜色
- SelectedItem - 获取选中的颜色项对象
- AutomaticColor - 「自动」按钮对应的默认颜色
Color Groups
颜色组
- RecentGroup - Recent colors collection
- StandardGroup - Standard colors collection
- ThemeGroup - Theme colors collection
- CustomGroups - User-defined color groups collection
- RecentGroup - 最近使用颜色集合
- StandardGroup - 标准颜色集合
- ThemeGroup - 主题颜色集合
- CustomGroups - 用户定义的颜色组集合
Visual Style
视觉样式
- Style - Visual style (Default, Office2007, Office2010, Office2016*, Metro)
- UseOffice2007Style - Enable/disable Office2007 styling
- Office2007Theme - Office2007 color scheme (Blue, Silver, Black, Managed)
- Style - 视觉样式(默认、Office2007、Office2010、Office2016*、Metro)
- UseOffice2007Style - 启用/禁用 Office2007 样式
- Office2007Theme - Office2007 配色方案(蓝色、银色、黑色、Managed)
Layout and Appearance
布局与外观
- ColorItemSize - Size of individual color items (default: 13x13)
- HorizontalItemsSpacing - Horizontal space between items (default: 4)
- VerticalItemsSpacing - Vertical space between items (default: 0)
- BorderStyle - Border appearance (None, FixedSingle, Fixed3D)
- BorderOffset - Border height (default: 3)
- TextAlign - Header text alignment (default: MiddleLeft)
- ButtonHeight - Height of automatic button (default: 23)
- ColorItemSize - 单个颜色项的大小(默认:13x13)
- HorizontalItemsSpacing - 项之间的水平间距(默认:4)
- VerticalItemsSpacing - 项之间的垂直间距(默认:0)
- BorderStyle - 边框外观(None、FixedSingle、Fixed3D)
- BorderOffset - 边框高度(默认:3)
- TextAlign - 头部文本对齐方式(默认:MiddleLeft)
- ButtonHeight - 自动按钮的高度(默认:23)
Events
事件
- Picked - Raised when a color is selected
- ItemSelection - Raised when mouse hovers over a color item
- Picked - 选中颜色时触发
- ItemSelection - 鼠标悬停在颜色项上时触发
Common Use Cases
常见用例
Use Case 1: Text Editor Color Selection
用例1:文本编辑器颜色选择
Implement color picker for changing text or background colors in a text editor.
csharp
private void SetupTextColorPicker()
{
textColorPicker.Style = ColorPickerUIAdv.visualstyle.Office2016Colorful;
textColorPicker.SelectedColor = richTextBox.SelectionColor;
textColorPicker.Picked += (s, e) => richTextBox.SelectionColor = e.Color;
}为文本编辑器实现用于修改文本或背景颜色的颜色选择器。
csharp
private void SetupTextColorPicker()
{
textColorPicker.Style = ColorPickerUIAdv.visualstyle.Office2016Colorful;
textColorPicker.SelectedColor = richTextBox.SelectionColor;
textColorPicker.Picked += (s, e) => richTextBox.SelectionColor = e.Color;
}Use Case 2: Drawing Application Color Palette
用例2:绘图应用调色板
Provide color selection for drawing tools with preview on hover.
csharp
private void SetupDrawingColorPicker()
{
colorPicker.Style = ColorPickerUIAdv.visualstyle.Office2016Black;
colorPicker.ItemSelection += (s, e) => ShowColorPreview(e.Color);
colorPicker.Picked += (s, e) => SetActiveBrushColor(e.Color);
}为绘图工具提供颜色选择功能,支持悬停预览。
csharp
private void SetupDrawingColorPicker()
{
colorPicker.Style = ColorPickerUIAdv.visualstyle.Office2016Black;
colorPicker.ItemSelection += (s, e) => ShowColorPreview(e.Color);
colorPicker.Picked += (s, e) => SetActiveBrushColor(e.Color);
}Use Case 3: Theme Color Customization
用例3:主题颜色自定义
Allow users to customize application theme colors with organized groups.
csharp
private void SetupThemeColorPicker()
{
// Add custom theme colors group
ColorUIAdvGroup themeGroup = new ColorUIAdvGroup();
themeGroup.Name = "Theme Colors";
// Add primary, accent, background colors
themeGroup.Items.Add(CreateColorItem(primaryColor, "Primary"));
themeGroup.Items.Add(CreateColorItem(accentColor, "Accent"));
themeGroup.Items.Add(CreateColorItem(backgroundColor, "Background"));
colorPicker.CustomGroups.Add(themeGroup);
colorPicker.Picked += ApplyThemeColor;
}允许用户通过有序分组的颜色选择器自定义应用主题颜色。
csharp
private void SetupThemeColorPicker()
{
// Add custom theme colors group
ColorUIAdvGroup themeGroup = new ColorUIAdvGroup();
themeGroup.Name = "Theme Colors";
// Add primary, accent, background colors
themeGroup.Items.Add(CreateColorItem(primaryColor, "Primary"));
themeGroup.Items.Add(CreateColorItem(accentColor, "Accent"));
themeGroup.Items.Add(CreateColorItem(backgroundColor, "Background"));
colorPicker.CustomGroups.Add(themeGroup);
colorPicker.Picked += ApplyThemeColor;
}Use Case 4: Form Designer Property Editor
用例4:表单设计器属性编辑器
Integrate color picker for property editing in a form designer tool.
csharp
private void ShowColorPickerForProperty(Control control, string propertyName)
{
ColorPickerUIAdv picker = new ColorPickerUIAdv();
picker.SelectedColor = (Color)control.GetType()
.GetProperty(propertyName)
.GetValue(control);
picker.Picked += (s, e) => {
control.GetType()
.GetProperty(propertyName)
.SetValue(control, e.Color);
};
ShowPickerInPopup(picker);
}在表单设计器工具中集成颜色选择器用于属性编辑。
csharp
private void ShowColorPickerForProperty(Control control, string propertyName)
{
ColorPickerUIAdv picker = new ColorPickerUIAdv();
picker.SelectedColor = (Color)control.GetType()
.GetProperty(propertyName)
.GetValue(control);
picker.Picked += (s, e) => {
control.GetType()
.GetProperty(propertyName)
.SetValue(control, e.Color);
};
ShowPickerInPopup(picker);
}Use Case 5: Conditional Formatting Color Selection
用例5:条件格式颜色选择
Provide color picker for conditional formatting rules in data grids.
csharp
private void SetupConditionalFormatColorPicker()
{
// Create custom group with warning/info/success colors
ColorUIAdvGroup formatGroup = new ColorUIAdvGroup();
formatGroup.Name = "Formatting Colors";
formatGroup.Items.Add(new GroupColorItem(formatGroup, Color.Red)); // Error
formatGroup.Items.Add(new GroupColorItem(formatGroup, Color.Orange)); // Warning
formatGroup.Items.Add(new GroupColorItem(formatGroup, Color.Yellow)); // Caution
formatGroup.Items.Add(new GroupColorItem(formatGroup, Color.LightGreen)); // Success
colorPicker.CustomGroups.Add(formatGroup);
colorPicker.Picked += ApplyConditionalFormatting;
}为数据网格中的条件格式规则提供颜色选择器。
csharp
private void SetupConditionalFormatColorPicker()
{
// Create custom group with warning/info/success colors
ColorUIAdvGroup formatGroup = new ColorUIAdvGroup();
formatGroup.Name = "Formatting Colors";
formatGroup.Items.Add(new GroupColorItem(formatGroup, Color.Red)); // Error
formatGroup.Items.Add(new GroupColorItem(formatGroup, Color.Orange)); // Warning
formatGroup.Items.Add(new GroupColorItem(formatGroup, Color.Yellow)); // Caution
formatGroup.Items.Add(new GroupColorItem(formatGroup, Color.LightGreen)); // Success
colorPicker.CustomGroups.Add(formatGroup);
colorPicker.Picked += ApplyConditionalFormatting;
}Troubleshooting
问题排查
Issue: Control Not Appearing in Toolbox
问题:控件没有出现在工具箱中
Solution: Install Syncfusion.Tools.WinForms NuGet package and rebuild solution.
解决方案: 安装 Syncfusion.Tools.WinForms NuGet 包并重新生成解决方案。
Issue: Colors Not Displaying Correctly
问题:颜色显示不正确
Solution: Ensure proper initialization of color groups before adding to form. Check SubItemsDepth and IsSubItemsVisible properties.
解决方案: 确保在添加到表单前正确初始化了颜色组,检查 SubItemsDepth 和 IsSubItemsVisible 属性。
Issue: Theme Not Applying
问题:主题不生效
Solution: Set UseOffice2007Style = true for Office2007 themes. For other styles, use the Style property directly.
解决方案: 对于 Office2007 主题需要设置 UseOffice2007Style = true,其他样式直接使用 Style 属性配置即可。
Issue: Events Not Firing
问题:事件不触发
Solution: Verify event handlers are attached after control initialization but before form load. Check that control is added to form's Controls collection.
解决方案: 确认事件处理程序在控件初始化后、表单加载前完成绑定,检查控件是否已添加到表单的 Controls 集合中。
Issue: Custom Groups Not Showing
问题:自定义组不显示
Solution: Ensure CustomGroups.Add() is called after creating and populating the ColorUIAdvGroup. Verify HeaderHeight is set appropriately.
解决方案: 确保在创建并填充 ColorUIAdvGroup 后调用了 CustomGroups.Add() 方法,检查 HeaderHeight 是否设置合理。
Next Steps
后续步骤
- Read getting-started.md for initial setup
- Explore color-groups.md to organize colors effectively
- Review appearance-styling.md for visual customization
- Implement event handling with events-selection.md
- Fine-tune layout using customization.md
- 阅读 getting-started.md 完成初始设置
- 查看 color-groups.md 学习如何高效组织颜色
- 参考 appearance-styling.md 实现视觉自定义
- 结合 events-selection.md 实现事件处理
- 通过 customization.md 精细调整布局