![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Feb 2005
Posts: 1
Rep Power: 0
![]() |
Hello, is there such a func that allows you to add (via a button click) to the clipboard.. say what is typed in the text feild? thanks
|
|
|
|
|
|
#2 | |
|
Professional Programmer
Join Date: Feb 2005
Location: PA, USA
Posts: 253
Rep Power: 4
![]() |
Quote:
Private Sub button1_Click(sender As Object, e As System.EventArgs)
' Takes the selected text from a text box and puts it on the clipboard.
If textBox1.SelectedText <> "" Then
Clipboard.SetDataObject(textBox1.SelectedText)
Else
textBox2.Text = "No text selected in textBox1"
End If
End Sub 'button1_Click
Private Sub button2_Click(sender As Object, e As System.EventArgs)
' Declares an IDataObject to hold the data returned from the clipboard.
' Retrieves the data from the clipboard.
Dim iData As IDataObject = Clipboard.GetDataObject()
' Determines whether the data is in a format you can use.
If iData.GetDataPresent(DataFormats.Text) Then
' Yes it is, so display it in a text box.
textBox2.Text = CType(iData.GetData(DataFormats.Text), String)
Else
' No it is not.
textBox2.Text = "Could not retrieve data off the clipboard."
End If
End Sub 'button2_Clicki recommend reading the whole page on it which can be found Here hope this helps ![]() |
|
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Jan 2005
Posts: 110
Rep Power: 4
![]() |
just to make it a bit simpler Clipboard.Clear 'Clears the current clipboard data Clipboard.SetText (TextBoxName.Text) 'Adds the text to clipboard |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|