如题 
谢谢~~~

解决方案 »

  1.   

    你的text是在什么控件里?????
      

  2.   

    TextBox.Lines 属性:public string[] Lines { get; set; }注意:
         该数组中的每个元素成为文本框控件中的一行文本。如果文本框控件的 Multiline 属性设置为 true,并且文本中出现换行符,则换行符后的文本被添加到该数组的一个新元素中,并显示在另一行上。实例:
    public void ViewMyTextBoxContents()
     {
        // Create a string array and store the contents of the Lines property.
        string[] tempArray = new string [textBox1.Lines.Length];
        tempArray = textBox1.Lines;
     
        // Loop through the array and send the contents of the array to debug window.
        for(int counter=0; counter < tempArray.Length;counter++)
        {
           System.Diagnostics.Debug.WriteLine(tempArray[counter]);
        }
     }
      

  3.   

    //又是API,不知道非API怎么写
            [DllImport("User32.DLL")]
            public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int iParam);        private const int EM_LINEFROMCHAR = 0xC9;
            private const int EM_LINEINDEX = 0xBB;        private void button6_Click(object sender, EventArgs e)
            {
                int Y = SendMessage(textBox1.Handle, EM_LINEFROMCHAR, textBox1.SelectionStart, 0);
                string S = textBox1.Lines[Y];
                int X = SendMessage(textBox1.Handle, EM_LINEINDEX, Y, 0);
                textBox1.SelectionStart = X;
                textBox1.SelectionLength = S.Length;
                textBox1.Focus;            Text = string.Format("当前光标停留在{0}行,本行的文字是{1}", Y, S);
            }