最近自学C#,做了记事本,就剩下查看一栏下的状态栏没做好。求高手指教。

解决方案 »

  1.   

    使用statusstrip控件。
    在菜单中编写:
    statusstrip1.Visible = !statusstrip1.Visible;
      

  2.   

    statusstrip添加了一个toolStripStatusLabel1
    int row = richTextBox1.GetLineFromCharIndex(richTextBox1.SelectionStart) + 1;
    int start = richTextBox1.GetFirstCharIndexOfCurrentLine();
    string s = richTextBox1.Text.Substring(start, richTextBox1.SelectionStart - start);toolStripStatusLabel1.Text = "第 " + row + " 行";
      

  3.   


    添加了一个toolStripStatusLabel1后,照以上方法试了一下,但是下面的状态栏只显示toolStripStatusLabel1
      

  4.   

    我的代码是这样的
    private void 状态栏SToolStripMenuItem_Click_1(object sender, EventArgs e)
            {
                if (k == -1)
                {
                    statusStrip1.Show();
                    状态栏SToolStripMenuItem.Checked = true;
                    k = 0;
                    int row = textBox1.GetLineFromCharIndex(textBox1.SelectionStart) + 1;
                    int start = textBox1.GetFirstCharIndexOfCurrentLine();
                    string s = textBox1.Text.Substring(start, textBox1.SelectionStart - start);                toolStripStatusLabel1.Text="Hello World";
                  
                }
                else
                {
                    statusStrip1.Hide();
                    状态栏SToolStripMenuItem.Checked = false;
                    k = -1;
                }
            }
      

  5.   

    写在TextBox的Click里面。真无语了,稍微动点脑子。
      

  6.   

    用StatusStrip控件。在状态栏菜单下边写:
          this.statusStrip1.Visible = !this.statusStrip1.Visible;      string str = "√状态栏";
          string str1 = " 状态栏";
          状态栏menuState.Text = this.statusStrip1.Visible ? str : str1;