2012-05-07 53 views

回答

5

將此函數添加到richtextbox.OnMouseMove事件中。

private void richTextBox2_MouseMove(object sender, MouseEventArgs e) 
     { 
      int c = richTextBox2.GetCharIndexFromPosition(new Point(e.X, e.Y)); 
      richTextBox2.Select(c, 1); 
      if (richTextBox2.SelectionFont.Bold) 
      { 
       richTextBox2.Cursor = Cursors.Hand; 
      } 
      else 
      { 
       richTextBox2.Cursor = Cursors.Default; 
      } 

     } 

你只需要1個字符就可以知道它是否爲粗體。

1
+0

感謝您的回答,但我的問題是第3步(•確定該索引是否超過粗體字符),如何確定而不更改SelectionStart和SelectionLength? –

相關問題