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

边栏推荐
- NameNode故障处理的两种方法
- FastAPI 封装一个通用的response
- Error EPERM operation not permitted, mkdir ‘Dsoftwarenodejsnode_cache_cacach两种解决办法
- SAP message TK 248 solved
- Comparison of ipv4 and ipv6 (IPV4)
- Using SQL Server FOR XML and FOR JSON syntax on other RDBMSs with jOOQ
- AMBA APB学习记录(AMBA 3/4)
- Hard disk partition, expand disk C, no reshipment system, not heavy D dish of software full tutorial.
- 基于生物激励神经网络的室内实时激光SLAM控制方法
- NameNode (NN) 和SecondaryNameNode (2NN)工作机制
猜你喜欢

Centos7 install mysql5.7

线性表的基本概念

IDEA连接MySQL数据库并执行SQL查询操作

NPM 使用介绍

Error EPERM operation not permitted, mkdir ‘Dsoftwarenodejsnode_cache_cacach两种解决办法
![[CPU Design Practice] Simple Pipeline CPU Design](/img/83/e1dfedfe2b2cfe83a34f86e252caa7.jpg)
[CPU Design Practice] Simple Pipeline CPU Design

手撕Verilog PWM呼吸灯

365天挑战LeetCode1000题——Day 044 最大层内元素和 层次遍历

PyQt5 rapid development and actual combat 9.7 Automated testing of UI layer

CentOS7 installation MySQL graphic detailed tutorial
随机推荐
【Shader】Shader官方示例[通俗易懂]
IDEA连接MySQL数据库并执行SQL查询操作
架构实战营|模块8
通过斐波那契数再谈函数递归2.0
Structural controllability of switched linear systems with symmetry constraints
CentOS7 - yum install mysql
串的基本概念与操作
系统集成项目管理工程师(软考中级)知识点总结【挣值分析】【关键路径】
PAT exam summary (exam experience)
Exploring Plain Vision Transformer Backbones for Object Detection Paper Reading Notes
IDEA版Postman插件Restful Fast Request,细节到位,功能好用
networkx绘制度分布
立方体IV(暑假每日一题 10)
Optimization of five data submission methods
0x80070570 The file or directory is damaged and cannot be deleted (how to delete 0x80070091)
PHP序列化:eval
PyQt5 rapid development and actual combat 10.1 Get city weather forecast
分布式锁有哪些,怎么实现(分布式锁的三种实现的对比)
CentOS7 —— yum安装mysql
Wearing detection and action recognition of protective gear based on pose estimation