TextBox文字前加行号

解决方案 »

  1.   

    就是我在一个TEXTBOX中输入了很的行的文字,我想的输入的换行的时候,自动在每一行前加一个行号,如:第一行就是
    1   dfsdfdsf
    2   df;ldkfdsl;f
    3   dfsdf
      

  2.   

    看下
    http://www.codeproject.com/cs/miscctrl/numberedtextbox.asp
      

  3.   

    private int ii = 1;
    private bool ff = false;private void textBox5_Enter(object sender, System.EventArgs e)
    {
    this.textBox5.Text += "1   >>>";
    this.textBox5.Select(this.textBox5.Text.Length,0);
    }private void textBox5_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
    {

     if(e.KeyChar == (Char)Keys.Enter)
     {
     ff = true;
     }
     else
     {
     ff = false;
     }
    }private void textBox5_TextChanged(object sender, System.EventArgs e)
    {
    if(ff)
    {
    ff = false;
    this.textBox5.Text +=  (++ii).ToString() + "   >>>";
    this.textBox5.Select(this.textBox5.Text.Length,0);

    }
    }
    -------------------------------------------------------------------
    没有考虑删除等问题。
      

  4.   

    楼主能把代码发给我吗?我邮箱是[email protected]谢谢了,急用