473,657 Members | 2,758 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 1217
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(s ender As Object, e As System.EventArg s)
' Declares an IDataObject to hold the data returned from the clipboard.
' Retrieves the data from the clipboard.
Dim iData As IDataObject = Clipboard.GetDa taObject()

' Determines whether the data is in a format you can use.
If iData.GetDataPr esent(DataForma ts.Text) Then
' Yes it is, so display it in a text box.
textBox2.Text = CType(iData.Get Data(DataFormat s.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
2485
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 clipboard it's content type is image/x-java-image and when I try to paste it in some Mac application (for example MS Worf for Mac OS) it doesn't work. I think that this happens, because Word doens't understand the image/x-java-image content type....
0
1452
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 paint or MS wordpad, then the bitmap is recognized be openoffice writer. Any Ideas???
3
4140
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, "c:\temp\Document.rtf", OpenMode.Binary, OpenAccess.Write FilePut(1, "c:\temp\on.gif" FileClose(1 Hope that somebody has an exampl Thanks
6
3438
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 there an easy way to save the clipboard contents and then restore it? Thanks
1
9015
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 graph area to the clip board (easy enough using Me.OleGraphControl.ChartArea.Copy). Next open an instance of MS Paint, paste the clipboard into the file and save as something like "Picture.bmp" in the same directory as the FE Access app. A...
1
3791
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 trouble pasting the formatted text into wordpad (which supports RTF formatting) but it won't paste into notepad (no RTF support). I know that if I copy something in wordpad with RTF formatting and then paste it into notepad the text will paste. What...
5
6857
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" widget in Tkinter? Here is my first attempt with just trying to print out the image data: ----------------- def pasteImg(tgt): global clipboardEnabled if not clipboardEnabled: return
5
1735
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 windows phone dialer program. The cursor flashes in the dialer's input area. I need some more script that can focus on that area or cursor position and paste the phone number there. Right now a CTRL-V works, but I want it automated in script. It...
0
999
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 results. I have also tried targeting x86 and x64 CPUs. I am developing on Windows Vista SP 1 x64. My problem is that when pasting to IE forms, nothing is pasted! It
0
8385
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8821
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8723
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8602
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6162
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1941
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.