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 + "列";
        }

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM