changing the clipboard

frix199

Member
Joined
Jul 18, 2005
Messages
19
Programming Experience
1-3
hello!!!

i want 2 add a textbox.text to the clipboard....
where is clipboard located??????
mayb i could try changing it...lol


bibiiiiiiiiiiiiiiiiiiiii
 
Well, dude i assume you need to copy to and from the Clipboard so the Clipboard serialize (and deserialize as well) it. However, serialization and deserialization happen automatically so, all you need is to set an attribute:

VB.NET:
<Serializable()> _[/size]
[size=2]Public Class myClass[/size]
[size=2]Public firstString As String [/size]
[size=2]Public secondString As String [/size]
[size=2]Public Sub New() [/size]
[size=2]End Sub Public [/size]
[size=2]Sub New(ByVal something As String, ByVal _ [/size]
[size=2]somethingElse As String) [/size]
[size=2]firstString = something [/size]
[size=2]secondString = somethingElse [/size]
[size=2]End Sub[/size]
[size=2]End Class[/size]
[size=2]
later in order to copy an object to the clipboard, the code below will pass the object to the Clipboard's SetDataObject method.

just join this code to your button named copy or whatever else

VB.NET:
Private Sub copy_Click(ByVal sender As System.Object, _ 
ByVal e As System.EventArgs) Handles copy.Click 
Dim myNewClass As New myClass(txtFirstTextBox.Text, _ 
txtSecondTextBox.Text) 
Clipboard.SetDataObject(myNewClass)
End Sub
Ask more if you find it confusing
Regards ;)
 
in VS2003 a clipboard object is declared for you (keword: clipboard) so all you gotta do is use it:

ClipBoard.SetDataObject(Textbox.Text)


also kulrom did post this part, it was just in the middle of all the code
 
Back
Top