StatusStrip控件

态栏用于显示用户状态的简短信息。

 

StatusStrip控件是由system.windows.forms.statusStrip类提供,作用是在应用程序中标识对话框底部的一栏,通常用于显示应用程序当前状态的简短信息。

 

StatusStrip中可以使用toolstrip中介绍的控件中的三个----ToolstripdropdownbuttontoolstripprogressbartoolstripSplitbutton

 

还有一个控件就是StatusStrip专用的,即StatusStripStatuslabel,作用就是使用文本和图像用户显示应用程序当前状态的信息。

namespace StatusStrip状态栏控件
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            toolStripStatusLabel1.Text = DateTime.Now.ToString();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            toolStripStatusLabel1.Text = DateTime.Now.ToString();
        }
        //鼠标点击事件
        private void textBox1_Click(object sender, EventArgs e)
        {
            //获取当前行第一个字符所在的索引值
            int index = textBox1.GetFirstCharIndexOfCurrentLine();

            //计算行号
            int line = textBox1.GetFirstCharIndexFromLine(index);

            //计算列数

            int column = textBox1.SelectionStart - index + 1;
            //如 textbox索引为 10 11 12 13 14 15 16  比如鼠标选择的是16 怎么计算是多少列呢
            //那index=10  column=selectionstart(当前选择起点16)-index(第一个索引值)+1=第7列

            toolStripStatusLabel3.Text = "第"+line+"行,第"+column+"列";
        }
        //键盘弹起事件
        private void textBox1_KeyUp(object sender, KeyEventArgs e)
        {
            //获取当前行第一个字符所在的索引值
            int index = textBox1.GetFirstCharIndexOfCurrentLine();

            //计算行号
            int line = textBox1.GetFirstCharIndexFromLine(index);

            //计算列数

            int column = textBox1.SelectionStart - index + 1;
            //如 textbox索引为 10 11 12 13 14 15 16  比如鼠标选择的是16 怎么计算是多少列呢
            //那index=10  column=selectionstart(当前选择起点16)-index(第一个索引值)+1=第7列

            toolStripStatusLabel3.Text = "第" + line+1 + "行" + "," + "第" + column + "列";
        }

  

原文地址:https://www.cnblogs.com/xiaowie/p/8624387.html