我有一个RichTextBox控件。当您在文本中单击鼠标左键时,光标将跳转到您单击的位置。我希望在我右键单击时也会发生这种情况。我不知道该怎么做。谢谢!
答案 0 :(得分:6)
假设winforms:
实现MouseUp事件处理程序,如下所示:
private void richTextBox1_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
RichTextBox box = (RichTextBox)sender;
box.SelectionStart = box.GetCharIndexFromPosition(e.Location);
box.SelectionLength = 0;
}
}