实现拖放功能WebBrowser控件Winforms C# [英] Implementing Drag and Drop Functionality WebBrowser Control Winforms C#

查看:239
本文介绍了实现拖放功能WebBrowser控件Winforms C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在WinForm C#中捕获WebBrowser控件的拖放事件。有没有办法?

解决方案

我的工作:



布尔成员变量,用于检测您是否从内部代码调用导航或从ouside代码调用导航。实施导航(BeforeNavigating)事件,并检查是否是来自外部的呼叫。



示例:



调用从里面导航:

  private void NavigateLocal(string htmlFileName)
{
this.localNavigate =真正;
this.webBrowser.Navigate(htmlFileName);
}

事件方法:

  private void WebBrowser_Navigating(object sender,WebBrowserNavigatingEventArgs e)
{
if(this.localNavigate)//内部调用
{
this .localNavigate = false;
}
else //从外面调用
{

this.DoDragDrop(e.Url.ToString());
}
}


I need to capture drag and Drop Events of WebBrowser Control in WinForm C#. Is there any way ?

解决方案

My Workarond:

use a boolean member variable to detect if you call navigate from inside code or navigating is called from ouside code. Implement the "Navigating" (BeforeNavigating) event and check if it was a call from outside.

Example:

call navigate from inside:

    private void NavigateLocal(string htmlFileName)
    {
        this.localNavigate = true;
        this.webBrowser.Navigate(htmlFileName);
    }

event method:

    private void WebBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
    {
        if (this.localNavigate)//inside call
        {
            this.localNavigate = false;
        }
        else //call from outside
        {

            this.DoDragDrop(e.Url.ToString());
        }
    }

这篇关于实现拖放功能WebBrowser控件Winforms C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆