|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Pasting from the clipboardI 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. Hamil,
There are many (good) samples for that in MSDN. http://msdn2.microsoft.com/en-us/library/system.windows.forms.clipboard.aspx I hope this helps, Cor 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 Show quoteHide quote "Cor Ligthert [MVP]" wrote: > Hamil, > > There are many (good) samples for that in MSDN. > > http://msdn2.microsoft.com/en-us/library/system.windows.forms.clipboard.aspx > > I hope this helps, > > Cor > > > Hamil,
I made this sample. http://www.vb-tips.com/default.aspx?ID=59f68564-b7a6-47a0-89ff-2c40276ff588 I hope this helps, Cor Works perfectly, I never would have figured this out on my own.
Thanks Hamil. Show quoteHide quote "Cor Ligthert [MVP]" wrote: > Hamil, > > I made this sample. > > http://www.vb-tips.com/default.aspx?ID=59f68564-b7a6-47a0-89ff-2c40276ff588 > > I hope this helps, > > Cor > > >
Seeking examples of screen scraping....
control arrays Setting MaxLength to <VBFixedString(x)>? GDI Question How Can I prevent a new row in datagrid But permit to edit existing cell ? HELP PLEASE !! DataGrid Questions VB.NET & Various Versions Of Outlook To use ShellExecute or not? Retrieving a webpage source HTM and checking for a string thereinL? User Control and Namespace question |
|||||||||||||||||||||||