Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Copying data into the Clipboard

Total Hit ( 3759)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Copying a piece of information into the clipboard is as easy as calling the Clipboard.SetDataObject: you can pass this method a string, an image, and so on. If you pass it a string that contains text in Rich Text Format (RTF), the Clipboard object detects this format automatically. For example, the following procedure copies the selected portion of a TextBox control (or the entire control's contents, if no text is selected) into the clipboard:

Click here to copy the following block
Sub CopyFromTextBox(ByVal tb As TextBox)
  ' Copy the TextBox's selected text to the clipboard.
  Dim t As String = tb.SelectedText
  ' Copy the entire Text, if no text is selected.
  If t.Length = 0 Then t = tb.Text
  ' Proceed only if there is something to be copied.
  If t.Length > 0 Then
    Clipboard.SetDataObject(t)
  End If
End Sub

The SetDataObject can take a second argument, which you should set to True if you want to make the copied object available after the current program terminates:

Click here to copy the following block
' Make the copied text available after the application ends.
    Clipboard.SetDataObject(t, True)

Remember that you can put any object in the clipboard, including objects that are private to your application and that shouldn't be accessed by other programs.


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.