How can I click a button in VB and highlight a text box and copies conent to clipboard?

风格不统一 提交于 2019-12-12 02:54:07

问题


This question is about having a button and text box. And when you click the button, the text in the text box highlights and is copied to your clipboard it one quick move. I'm building this code in VB (Microsoft, Visual Basic 2010).

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
       [...]
End Sub

Awaiting the answer. Thanks.


回答1:


Try this:

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Clipboard.SetText(Me.TextBox1.Text, TextDataFormat.Text)
End Sub


来源:https://stackoverflow.com/questions/9117087/how-can-i-click-a-button-in-vb-and-highlight-a-text-box-and-copies-conent-to-cli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!