在vb.net中更改右键单击事件上的文本框光标位置

时间:2014-07-31 15:02:15

标签: vb.net

我在Vb.net中的应用程序类似于通过使用右键单击上下文菜单进行复制粘贴操作,其中包含剪切,复制和粘贴选项。复制文本后,我希望将文本放在文本框中发生右键单击的位置。复制粘贴操作类似于windows app notepad ++。文本框不是多行的。 我已根据我推荐的帖子使用了以下代码。

Private Sub TextBox1_MouseClick(sender As Object, e As MouseEventArgs) Handles TextBox1.MouseClick

    If (e.Button = Windows.Forms.MouseButtons.Right) Then

        If (TextBox1.SelectionLength = 0) Then

            TextBox1.Focus()
            TextBox1.HideSelection = True
            TextBox1.SelectionStart = TextBox1.GetCharIndexFromPosition(e.Location)

        End If
    End If
End Sub

0 个答案:

没有答案
相关问题