2011-04-17 52 views

回答

4
  1. 獲取TextBox中插入符號的索引:

    C#

    int caretIndex = textBox.SelectionStart; 
    

    VB.NET

    Dim caretIndex As Integer = textBox.SelectionStart 
    
  2. 獲得從插入符號索引的行號:

    C#

    int lineNumber = textBox.GetLineFromCharIndex(caretIndex); 
    

    VB.NET

    Dim lineNumber As Integer = textBox.GetLineFromCharIndex(caretIndex) 
    
  3. 獲取當前行的字符索引:

    C#

    Point characterXY = textBox.GetPositionFromCharIndex(caretIndex); 
    int characterIndex = textBox.GetCharIndexFromPosition(characterXY); 
    

    VB.NET

    Dim characterXY As Point = textBox.GetPositionFromCharIndex(caretIndex) 
    Dim characterIndex As Integer = textBox.GetCharIndexFromPosition(characterXY) 
    

我想你可以繼續從這裏...