Vb.net drop file on form




















Allow Drop Property Reference Is this page helpful? Please rate your experience Yes No. Any additional feedback? Namespace: System. Forms Assembly: System. Gets or sets a value indicating whether the control can accept data that the user drags onto it. Create a Visual Basic. Place two textboxes and set Allowdrop property of a second textbox to true. Add the following code.

In the above example, the MouseDown event is used to set a flag showing that the mouse is down, and then the DoDragDrop method is called in the MouseMove event. Although you could initiate the drag in the MouseDown event, doing so would create undesirable behavior: Every time a user clicks the control, the no-drag cursor would be displayed.

Data parameter, which in this case takes the Text property of the TextBox. Although unnecessary in this example, if you had multiple controls that support dragging you could get a run-time exception.

In this case it is text, so the Effect property is set to Copy, which in turn displays the copy cursor.

The next section provides an example of dragging a different type of data and providing support for both cutting and copying. This is necessary because the AllowDrop property is not available at design time. So if two text files are dragged from the desktop to the application, the string array will contain two file paths.

The last step is to loop through the file paths and use the StreamReader to read the contents of the text file. I hope this article was useful and I thank you for viewing it. Was this article worth reading? Share it with fellow developers too. Feedback - Leave us some adulation, criticism and everything in between! Good to see the. NET platform mostly succeeds at keeping things simple. Comment posted by praveen on Monday, September 15, PM good code NET application?

Post the code that causes error or mail me the project using the Contact page. I am building this in C using. When I drag the files over I get the "not here" cursor Any ideas? Sathish Kumar. Comment posted by varun on Thursday, April 8, AM really heplful. Can you tell me how i can resolve this issue? Thanks v Comment posted by Dave on Friday, April 12, AM Too bad this code as written copied verbatim does not work at all in Windows 7.

Thanks so much! Helped me with my application. Contents Exit focus mode. Please rate your experience Yes No. Any additional feedback? Submit and view feedback for This product This page. View all page feedback.



0コメント

  • 1000 / 1000