Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Copy Text to clipboard

$
0
0

Dear Friends,

In my Web browser application using VB2010, I have a TextBox1, a ComboBox1 and a WebBrowser1 controls.

When I select (highlight) a text to copy to clipboard, whether on the web browser or on a textbox, I need to be able to copy to the clipboard.

That is, I need the application to detect which control's text is selected to be copied.

Please help me with some ideas. 

Thank you.


Eyo Honesty

Here is my piece of code below.

 Private Sub copyItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles copyItem.Click
        For Each ctl As Control In Controls
            If TypeOf ctl Is TextBox Then
                If ctl.Focused Then
                    Clipboard.SetText(ctl.Text)
                End If
            ElseIf TypeOf ctl Is ComboBox Then
                If ctl.Focused Then
                    Clipboard.SetText(ctl.Text)
                End If
            ElseIf TypeOf ctl Is WebBrowser Then
                If ctl.Focused Then
                    Clipboard.SetText(ctl.Text)
                End If
            End If
        Next


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>