mcpField
S
syncfusion-winforms-statusstrip

syncfusion-winforms-statusstrip

github.com/syncfusion设计与 UI277 次安装1 周前更新
代码仓库

关于 syncfusion-winforms-statusstrip

面向 Windows Forms 开发者的 Syncfusion StatusStripEx 实现指南,用于在窗体或 Ribbon 底部构建状态栏。内容涵盖多种状态项、Office 主题、颜色方案和尺寸调节手柄。

主要功能

  1. 01添加标签、按钮、下拉项和滑块
  2. 02显示进度条与通知项
  3. 03应用 Office2007 和 Office2016 样式
  4. 04自定义颜色方案与上下文菜单
  5. 05配置尺寸调节手柄

适用场景

  1. 01在文档编辑器中显示页码、字数和缩放控制
  2. 02展示数据应用的连接状态与记录数
  3. 03在后台任务期间显示进度
  4. 04为 Ribbon 应用添加状态栏

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/syncfusion/winforms-ui-components-skills --skill syncfusion-winforms-statusstrip

安装后在 Claude Code 中输入/syncfusion-winforms-statusstrip确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

references/
getting-started.md
sizing-grip.md
status-items.md
styling-and-appearance.md

详细介绍

实现 Syncfusion WinForms StatusStripEx

StatusStripEx 控件提供增强型状态栏,可添加到窗体或 Ribbon 控件的底部。它支持多种项类型、Office 主题、自定义颜色和灵活定位,可用于创建专业的状态栏。

何时使用此技能

在用户需要以下功能时使用此技能:

  • 应用程序状态栏: 在窗体底部显示应用程序状态、用户信息或系统状态
  • 进度指示器: 在状态栏中显示进度条或加载指示器
  • Ribbon 状态栏: 在 RibbonControlAdv 底部添加状态栏
  • 左右对齐: 使用不同的项类型,分别显示左对齐的通知和右对齐的状态
  • 主题化状态栏: 使用 Office2007(Silver/Blue/Black)或 Office2016 主题
  • 自定义状态项: 按钮、标签、下拉按钮、拆分按钮、进度条、跟踪栏
  • 大小调整握柄: 自定义握柄外观的可调整大小窗体指示器
  • 状态信息: 显示文件信息、记录数、缩放级别、连接状态
  • Word 风格上下文菜单: 为状态项自定义上下文菜单

组件概览

StatusStripEx(Syncfusion.Windows.Forms.Tools.StatusStripEx)是一种增强型状态栏控件,支持:

  • 两种项类型:
    • StatusControl 项: 右对齐(StatusLabel、ProgressBar、DropDownButton、SplitButton、PanelItem、TrackBarItem)
    • 通知项: 左对齐(StatusStripButton、StatusStripLabel、StatusStripProgressBar 等)
  • Office2007 配色方案: Silver、Blue、Black
  • Office2016 视觉样式: Colorful、White、Black、DarkGray
  • 自定义管理颜色: 应用自定义颜色主题
  • 大小调整握柄: 在右下角自定义调整大小握柄
  • 智能标记支持: 通过设计器快速添加项
  • 自定义上下文菜单: Word2007 风格状态栏上下文菜单
  • Ribbon 集成: 可与 RibbonControlAdv 无缝配合使用

主要命名空间: Syncfusion.Windows.Forms.Tools

程序集: Syncfusion.Tools.Windows.dll(及其依赖项)


文档与导航指南

入门

📄 阅读: references/getting-started.md

阅读时机: 用户需要安装、配置或创建第一个 StatusStripEx 时。

涵盖主题:

  • 程序集部署和 NuGet 包安装
  • 通过设计器(工具箱)添加 StatusStripEx
  • 通过代码添加 StatusStripEx
  • 将其停靠在窗体或 Ribbon 底部
  • 用于添加项的 Items Collection Editor
  • 支持通过智能标记快速添加项
  • 基本状态栏设置
状态项与集合

📄 阅读: references/status-items.md

阅读时机: 用户希望添加状态标签、进度条或按钮,或了解项的定位方式时。

涵盖主题:

  • StatusControl 项(右对齐):StatusLabel、ProgressBar、DropDownButton、SplitButton、PanelItem、TrackBarItem
  • 通知项(左对齐):StatusStripButton、StatusStripLabel、StatusStripProgressBar、StatusStripDropDownButton 等
  • StatusControl 项与通知项的区别
  • 通过 Items 集合以编程方式添加项
  • 项的定位和对齐策略
  • 有效使用不同的项类型
大小调整握柄自定义

📄 阅读: references/sizing-grip.md

阅读时机: 用户需要显示或隐藏大小调整握柄,或自定义其外观时。

涵盖主题:

  • 大小调整握柄概览及用途
  • SizingGrip 属性(true/false)
  • GripStyle 属性(Visible、Hidden)
  • 用于设置间距的 GripMargin 属性
  • 自定义握柄外观
  • 何时显示或隐藏大小调整握柄
样式和外观

📄 阅读: references/styling-and-appearance.md

适用情况: 用户需要 Office2007/2016 主题或自定义状态栏颜色。

涵盖主题:

  • Office2007 配色方案(Silver、Blue、Black)
  • OfficeColorScheme 属性的用法
  • Office2016 视觉样式(Colorful、White、Black、DarkGray)
  • VisualStyle 属性配置
  • 使用 ApplyManagedColors 自定义托管颜色
  • 自定义上下文菜单(Word2007 风格)
  • 上下文菜单项的 StatusString 属性

快速入门示例

包含项的基本 StatusStripEx
using Syncfusion.Windows.Forms.Tools;
using System.Windows.Forms;

// Create StatusStripEx
StatusStripEx statusStripEx1 = new StatusStripEx();

// Create status label (right-aligned)
ToolStripStatusLabel statusLabel = new ToolStripStatusLabel();
statusLabel.Text = "Ready";

// Create progress bar (right-aligned)
ToolStripProgressBar progressBar = new ToolStripProgressBar();
progressBar.Value = 50;

// Add items to StatusStripEx
statusStripEx1.Items.AddRange(new ToolStripItem[] {
    statusLabel,
    progressBar
});

// Dock to bottom
statusStripEx1.Dock = DockStyleEx.Bottom;

// Add to form
this.Controls.Add(statusStripEx1);
使用 Office2016 主题的 StatusStripEx
// Apply Office2016 Colorful theme
statusStripEx1.VisualStyle = StatusStripExStyle.Office2016Colorful;

// Enable sizing grip
statusStripEx1.SizingGrip = true;
statusStripEx1.GripStyle = ToolStripGripStyle.Visible;

常见模式

包含多个项的应用程序状态栏
// Create StatusStripEx
StatusStripEx statusBar = new StatusStripEx();
statusBar.Dock = DockStyleEx.Bottom;

// Left-aligned notification item
ToolStripStatusLabel notificationLabel = new ToolStripStatusLabel();
notificationLabel.Text = "Connection: Active";
notificationLabel.Spring = true;  // Fill available space

// Right-aligned status items
ToolStripStatusLabel recordLabel = new ToolStripStatusLabel();
recordLabel.Text = "Records: 1,234";

ToolStripProgressBar loadingProgress = new ToolStripProgressBar();
loadingProgress.Visible = false;  // Show when loading

ToolStripStatusLabel zoomLabel = new ToolStripStatusLabel();
zoomLabel.Text = "Zoom: 100%";

// Add all items
statusBar.Items.AddRange(new ToolStripItem[] {
    notificationLabel,
    recordLabel,
    loadingProgress,
    zoomLabel
});

this.Controls.Add(statusBar);

适用情况: 用于显示各种应用程序状态的多用途状态栏。

状态栏中的进度指示器
// Status bar with progress tracking
StatusStripEx statusBar = new StatusStripEx();

ToolStripStatusLabel statusText = new ToolStripStatusLabel();
statusText.Text = "Processing...";

ToolStripProgressBar progressBar = new ToolStripProgressBar();
progressBar.Style = ProgressBarStyle.Continuous;
progressBar.Maximum = 100;

statusBar.Items.AddRange(new ToolStripItem[] { statusText, progressBar });
statusBar.Dock = DockStyleEx.Bottom;

// Update progress
void UpdateProgress(int percent)
{
    progressBar.Value = percent;
    statusText.Text = $"Processing... {percent}%";
}

适用情况: 需要提供进度反馈的长时间运行操作。

带有 StatusStripEx 的功能区
// StatusStripEx at bottom of Ribbon form
StatusStripEx ribbonStatusBar = new StatusStripEx();
ribbonStatusBar.Dock = DockStyleEx.Bottom;

// Apply matching Office2016 theme
ribbonStatusBar.VisualStyle = StatusStripExStyle.Office2016Colorful;

// Add status items
ToolStripStatusLabel pageLabel = new ToolStripStatusLabel();
pageLabel.Text = "Page 1 of 10";

ToolStripStatusLabel wordCount = new ToolStripStatusLabel();
wordCount.Text = "Words: 245";

ribbonStatusBar.Items.AddRange(new ToolStripItem[] { pageLabel, wordCount });

// Add to form (ensure it's added after Ribbon)
this.Controls.Add(ribbonStatusBar);

适用情况: 需要显示状态信息的基于功能区的应用程序。

自定义主题状态栏
// Apply custom managed color
statusStripEx1.OfficeColorScheme = ToolStripEx.ColorScheme.Managed;
Office2007Colors.ApplyManagedColors(this, Color.DarkBlue);

// Custom context menu for status items
ToolStripStatusLabel statusLabel = new ToolStripStatusLabel();
statusLabel.Text = "Pages";
statusLabel.StatusString = "1/1";  // Shows in Word-style context menu

适用情况: 采用自定义配色方案的品牌应用程序。


关键属性

核心属性
属性类型描述适用情况
ItemsToolStripItemCollection状态项集合添加/管理状态栏项
DockDockStyleEx停靠位置(底部)将状态栏置于底部
SizingGripbool显示/隐藏尺寸调整手柄启用窗体尺寸调整指示器
GripStyleToolStripGripStyle手柄可见性样式自定义手柄外观
GripMarginPadding手柄边距调整手柄位置
样式属性
属性类型描述适用情况
VisualStyleStatusStripExStyleOffice2016 视觉样式应用 Office2016 主题
OfficeColorSchemeColorSchemeOffice2007 配色方案应用 Silver/Blue/Black 主题
项目类型

StatusControl 项(右对齐):

  • StatusLabel - 用于显示状态信息的文本标签
  • ProgressBar - 进度指示器
  • DropDownButton - 用于显示选项的下拉按钮
  • SplitButton - 带下拉菜单的分割按钮
  • PanelItem - 自定义面板容器
  • TrackBarItem - 滑块控件

通知项(左对齐):

  • StatusStripButton - 按钮控件
  • StatusStripLabel - 文本标签
  • StatusStripProgressBar - 进度指示器
  • StatusStripDropDownButton - 下拉按钮
  • StatusStripSplitButton - 分割按钮
  • StatusStripPanelItem - 自定义面板

常见用例

1. 文档编辑器状态栏

场景: 类似 Word 的编辑器显示页码、字数和缩放比例。

  • 添加 StatusLabel 显示页码(例如,“第 1 页,共 5 页”)
  • 添加 StatusLabel 显示字数(例如,“字数:1,234”)
  • 添加 TrackBarItem 作为缩放控件
  • 使用 Office2016Colorful 主题,呈现现代外观
  • 阅读:status-items.md、styling-and-appearance.md
2. 显示记录数的数据应用程序

场景: 数据库应用程序显示记录数和连接状态。

  • 左对齐的通知标签显示连接状态
  • 右对齐的标签显示记录数
  • 使用 ProgressBar 显示数据加载操作的进度
  • 阅读:status-items.md
3. 显示状态信息的文件管理器

场景: 文件管理器显示所选项目和总大小。

  • StatusLabel:“已选择 5 个项目”
  • StatusLabel:“总计:2.5 GB”
  • StatusLabel:“剩余空间:150 GB”
  • 阅读:getting-started.md
4. 带有后台任务的应用程序

场景: 在状态栏中显示后台任务进度。

  • StatusStripLabel:任务描述(左对齐)
  • StatusStripProgressBar:任务进度(左对齐)
  • 任务完成后隐藏进度条
  • 阅读:status-items.md
5. 品牌应用程序状态栏

**场景:**自定义颜色主题,与品牌形象保持一致。

  • 将 OfficeColorScheme 设置为 Managed
  • 使用 ApplyManagedColors 应用自定义颜色
  • 让状态栏与应用程序主题保持一致
  • 阅读:styling-and-appearance.md
6. Ribbon 应用程序状态栏

**场景:**适用于 RibbonControlAdv 应用程序的状态栏。


最佳实践

  1. **项目对齐:**使用 StatusControl 项目右对齐,使用 Notification 项目左对齐
  2. **主题一致性:**让 StatusStripEx 样式与应用程序主题(Office2007/2016)保持一致
  3. **大小调整手柄:**可调整大小的窗体启用,固定大小的窗体禁用
  4. **进度指示器:**仅在操作期间显示 ProgressBar,完成后将其隐藏
  5. **Spring 属性:**在左侧项目上使用 Spring=true,将右侧项目推至右侧
  6. **项目数量:**状态栏项目保持精简(3-6 项),以便清晰显示
  7. **文本更新:**动态更新状态文本,以反映应用程序状态
  8. **Ribbon 兼容性:**在 Ribbon 后添加 StatusStripEx,以确保正确停靠

另请参阅

评论

支持 Markdown