In WebBrowser control of .NET Winform, there is no drag & drop event. But we had a requirement to catch the dropped files. By using beforenavigate event, we can catch only one dropped file and not able to pick up all the dropped files.
The simple trick is to disable the Web browser control while dropping, so that the form dragdrop event will be fired, from where we can get all the files. But there is no disable property for Webbrowser control. To overcome that, place the webbrowser control inside a Panel & disable the panel, so that the webbrowser control will also be disabled.
Next question will be, When to disable the Panel control ?
Form Activate / Deactivate, since while we start dragging a file obviously the form will be deactivated & we can disable the Panel. On(after) drop, the form will be activated & can enable the Panel control.
The code is :
1. In Form1, placed the webbrowser control in the “Panel1″ panel control.
2. Applied the following code in your form
The simple trick is to disable the Web browser control while dropping, so that the form dragdrop event will be fired, from where we can get all the files. But there is no disable property for Webbrowser control. To overcome that, place the webbrowser control inside a Panel & disable the panel, so that the webbrowser control will also be disabled.
Next question will be, When to disable the Panel control ?
Form Activate / Deactivate, since while we start dragging a file obviously the form will be deactivated & we can disable the Panel. On(after) drop, the form will be activated & can enable the Panel control.
The code is :
1. In Form1, placed the webbrowser control in the “Panel1″ panel control.
2. Applied the following code in your form
|
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
No comments:
Post a Comment