当前位置:网站首页>C#控件StatusStrip使用
C#控件StatusStrip使用
2022-07-31 12:54:00 【黄昏和星空】
StatusStrip控件:状态栏控件。通常处于窗体的最底层,用于显示窗体上的对象的相关信息,或者显示应用程序的信息。
包含:StatusLabel、progressBar、DropDownButton、splitButton控件。可以显示文本、图标或者同时显示这两者。
使用例子: this.toolStripStatusLabel2.Text = DateTime.Now.ToShortDateString();//在任务栏上显示系统的当前日期
先了解一下StatusStrip:首选StatusStrip是Form中的一个控件,同时也是一个大的控件,其中含有许多子控件,这些子控件存放在控件群中。
这样我们要使用StatusStrip时,
首先要定义StatusStrip,
然后定义ToolStrip控件,
再次定义ToolStrip控件群,
第三将ToolStrip控件加入到控件群中,
第四将控件群加入到StatusStrip中,
最后要将StatusStrip加入到窗体中。
举例说明:
本例是在Form窗体中加入任务栏,并在任务栏左边显示Test。
一、在设计模式下的添加方法为:
在窗体上添加一个StatusStrip控件。在StatusStrip上添加一个ToolStripLabel控件。将ToolStripLabel控件的Text属性设置成在运行时显示的消息(即为Test)。
二、 在代码模式下添加过程即为:
定义StatusStrip
定义控件(ToolStripLabel)
定义控件群(ToolStripItem)
将控件加入控件群(Items.AddRange)
将StatusStrip加入到Form中
public Form1()
{
InitializeComponent();
#region AddStatusStrip
//1. 定义要增加的StatusStrip
StatusStrip sb = new StatusStrip();
//2. 定义StatusStrip项目中的控件,其中ToolStripLabel是一个相似于label的控件,现在用于显示文字
ToolStripLabel tsl = new ToolStripLabel();
//要显示的文字内容
tsl.Text = “Test”;
//3. 定义StatusStrip中要项目
ToolStripItem[] tsi = new ToolStripItem[1];
tsi[0] = tsl;
//4. 将项目加入到StatusStrip中
sb.Items.AddRange(tsi);
//5. 将StatusStrip加入到窗体中
this.Controls.Add(sb);
#endregion
}
MenuStrip:
在窗体上添加菜单栏控件 MenuStrip,直接按住 MenuStrip 不放,将其拖到右边的 Windows 窗体中即可
StatusStrip:
用于在界面中给用户一些提示,例如登录到一个系统后,在状态栏上显示登录人的用户名、系统时间等信息。
在状态栏上不能直接编辑文字,需要添加其他的控件来辅助。
单击上图所示界面中新添加的状态栏控件,则会显示如下图所示的下拉菜单,
其中包括标签控件(StatusLabel)、进度条(ProgressBar)、下拉列表按钮(DropDownButton)、分割按钮(SplitButton)。
ToolStrip:
在工具箱中将 ToolStrip 控件直接拖到 Windows 窗体中即可。
为了美观和界面的统一,应将其拖到菜单栏的下方,如下图所示。

边栏推荐
- anaconda虚拟环境安装pytorch gpu版本
- Optimization of five data submission methods
- The function of SQL GROUP BY dependence
- Markdown编辑器语法
- Anaconda安装labelImg图像标注软件
- Spark GC日志分析
- Architecture Camp | Module 8
- IDEA版Postman插件Restful Fast Request,细节到位,功能好用
- Flutter键盘可见性
- Build a Valentine's Day confession website (super detailed process, package teaching package)
猜你喜欢
CWE4.8 -- 2022年危害最大的25种软件安全问题
深入浅出边缘云 | 4. 生命周期管理
2022年最新重庆建筑安全员模拟题库及答案
深圳某游戏研发公司每个工位都装监控,网友:堪比“坐牢”!
函数递归1.0
Exploring Plain Vision Transformer Backbones for Object Detection Paper Reading Notes
PyQt5快速开发与实战 10.1 获取城市天气预报
networkx绘制度分布
PyQt5 rapid development and actual combat 10.1 Get city weather forecast
alert(1) (haozi.me)靶场练习
随机推荐
dosbox基础使用[通俗易懂]
小试牛刀—猜数字游戏
Architecture Camp | Module 8
NameNode (NN) 和SecondaryNameNode (2NN)工作机制
jmeter性能测试步骤入门(性能测试工具jmeter)
一文吃透哈希表
[RPI]树莓派监控温度及报警关机保护「建议收藏」
模拟量差分和单端(iou计算方法)
行业案例 | 全面防护 赛宁助力能源工控安全建设
Banyan Tree Loan GPU Hardware Architecture
Adding data nodes and decommissioning data nodes in the cluster
PyQt5 rapid development and actual combat 9.7 Automated testing of UI layer
ASM module in SAP Ecommerce Cloud Spartacus UI and Accelerator UI
深圳某游戏研发公司每个工位都装监控,网友:堪比“坐牢”!
FastAPI 封装一个通用的response
SAP message TK 248 solved
0x80070570文件或目录损坏且无法删除(0x80070091怎么删除)
CentOS7 安装MySQL 图文详细教程
串的基本概念与操作
anaconda虚拟环境安装pytorch gpu版本