当前位置:网站首页>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 窗体中即可。
为了美观和界面的统一,应将其拖到菜单栏的下方,如下图所示。

边栏推荐
- networkx绘制度分布
- Three-Phase PWM Rectifier Predictive Direct Power Control
- 关于我放弃考研这件事儿
- Double non-one into bytes!!Pure dry goods sharing
- Using SQL Server FOR XML and FOR JSON syntax on other RDBMSs with jOOQ
- 电商rpa是什么意思?跟电商rpi是一个意思吗?
- 基于verilog的CRC校验(汇总)
- 使用docker搭建mysql主从
- ASM外部冗余是否可以替换磁盘
- SAP message TK 248 solved
猜你喜欢
随机推荐
PyQt5 rapid development and actual combat 9.7 Automated testing of UI layer
函数递归1.0
Json和对象之间转换的封装(Gson)
SAP 电商云 Spartacus UI 和 Accelerator UI 里的 ASM 模块
IDEA版Postman插件Restful Fast Request,细节到位,功能好用
AMBA APB学习记录(AMBA 2.0)
Flutter键盘可见性
Basic use of dosbox [easy to understand]
CWE4.8 -- 2022年危害最大的25种软件安全问题
P5019 [NOIP2018 提高组] 铺设道路
WPF中报错:“未将对象引用设置到对象的实例。”
FastAPI encapsulates a generic response
PyQt5 rapid development and actual combat 10.2 compound interest calculation && 10.3 refresh blog clicks
Getting started with jmeter performance testing steps (performance testing tool jmeter)
Wearing detection and action recognition of protective gear based on pose estimation
Double non-one into bytes!!Pure dry goods sharing
go中select语句
集群中增加数据节点与退役数据节点
函数的参数
PAT考试总结(考试心得)








