態欄用於顯示用戶狀態的簡短信息。
StatusStrip控件是由system.windows.forms.statusStrip類提供,作用是在應用程序中標識對話框底部的一欄,通常用於顯示應用程序當前狀態的簡短信息。
在StatusStrip中可以使用toolstrip中介紹的控件中的三個----Toolstripdropdownbutton、toolstripprogressbar、toolstripSplitbutton
還有一個控件就是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 + "列"; }