2011-04-17 51 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) 
    

我想你可以继续从这里...