gpt4 book ai didi

C# 右键单击​​ RichTextBox 中的移动光标

转载 作者:太空狗 更新时间:2023-10-30 00:36:01 26 4
gpt4 key购买 nike

我有一个 RichTextBox 控件。当您在文本中左键单击时,光标会跳到您单击的位置。我也希望在右键单击时发生这种情况。我不知道该怎么做。谢谢!

最佳答案

假设 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;
}
}

关于C# 右键单击​​ RichTextBox 中的移动光标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2996643/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com