473,503 Members | 3,247 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pasting from the clipboard

I would like to right click and select (copy )a file (or directory) name in
Windows Explorer and then paste the file (or directory) name into a text box
on a vb.net form. Can anyone explain how to do this?
thanks.
Hamil.

Jan 13 '06 #1
4 1208
Hamil,

There are many (good) samples for that in MSDN.

http://msdn2.microsoft.com/en-us/lib...clipboard.aspx

I hope this helps,

Cor
Jan 13 '06 #2
I have tried to modify the msdn example but I have not succeeded. I have
tried their example code and it works. The example copies test from notepad
or text box. I want to be able to transfer a selected filename from a
windows explorer pane into my application, a textbox for example. The
following code, taken from msdn works for text. How would I modify it to
make it extract the filename as I have described above.

I used another example to get the dataformats from the clipboard object and
FileName was one of the items listed. However, when I try to change "text"
in the example below to 'FileName" it doesn't work.

I suspect a minor fix would solve my problem.
Thanks
Hamil.

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_Click

"Cor Ligthert [MVP]" wrote:
Hamil,

There are many (good) samples for that in MSDN.

http://msdn2.microsoft.com/en-us/lib...clipboard.aspx

I hope this helps,

Cor

Jan 13 '06 #3
Hamil,

I made this sample.

http://www.vb-tips.com/default.aspx?...f-2c40276ff588

I hope this helps,

Cor
Jan 14 '06 #4
Works perfectly, I never would have figured this out on my own.
Thanks
Hamil.
"Cor Ligthert [MVP]" wrote:
Hamil,

I made this sample.

http://www.vb-tips.com/default.aspx?...f-2c40276ff588

I hope this helps,

Cor

Jan 15 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2460
by: Vlado | last post by:
Hello, I need to copy/paste image from Java application to/from the System clipboard. On windows everything is just fine, but on Mac OS is not. The problem is that when I transfer image to the...
0
1440
by: semhelp | last post by:
I am using VB.net to put a bitmap on the clipboard. MS paint and MS wordpad recognize the bitmap on the clipboard, but openoffice Writer does not. If I put the bitmap on the clipboard from MS...
3
4124
by: sneffe | last post by:
Hi, Does anyone have an example of how to paste or inserting an image into a rtf file? I have tried the following but the image is represented as a lot of weird letters and numbers FileOpen(1,...
6
3430
by: Just Me | last post by:
I've seen code that copies a bmp file into a RichTextBox by first putting it into the clipboard and then using Paste to get it into the RichtextBox. This destroys the clipboard contents. Is...
1
8962
by: Tim Marshall | last post by:
In my not too successful attempts to get an OLE chart object (Graph 11.0) that has been manipulated on a form to be reproduced on a report, I am considering the following procedure. First copy the...
1
3781
by: Grant Smith | last post by:
I've got an application that I can copy some text out of the RichTextBox control. I would like to keep the formatting so I'm able to copy it to the Clipboard with RTF formatting. I have no...
5
6825
by: exhuma.twn | last post by:
As many might know, windows allows to copy an image into the clipboard by pressing the "Print Screen" button on the keyboard. Is it possible to paste such an image from the clipboard into a "Text"...
5
1722
by: bshul | last post by:
Hi, I am hoping someone knows how to finish this javascript. The script copies selected text to the windows clipboard from, for instance, a webpage. This text is a phone number. It then executes the...
0
982
by: monty0018 | last post by:
Hi, I'm writing a custom clipboard application in VB .NET 2008 similar to Ditto (http://ditto-cp.sourceforge.net/). I have tried targeting .NET Frameworks 2.0, 3.0, and 3.5 with the same...
0
7194
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5566
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4993
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
729
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
372
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.