开发者

WindowsFormsWebBrowser drag drop functionality

I have a windows forms webbrowser (Windows.Forms.WebBrowser) I want to capture the drag drop event over it.

I did not see any drag drop events on it that I can hook into ? It just has DoDragDrop()

Could you please guide me as to how to capture the drag drop event on it? I want to handle these events in a parent control that hosts it.

Th开发者_Python百科anks!


You can enable Drag Drop on the WebBrowser control via the "AllowWebBrowserDrop" property, i.e.

webBrowser1.AllowWebBrowserDrop = true;

Then you can intercept the "Navigating" event to read the URL that was dropped:

  private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
  {
     MessageBox.Show(e.Url.ToString());
  }


To cancel the navigation event, do this:

e.Cancel = true;

This should do the trick.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜