日期:2014-05-17  浏览次数:20898 次

c# Winform和webbrower控件交互问题 急问
winform程序里有webbrower控件,嵌套这一个web程序,现在要想再web程序做的操作能让winform知道,
或者webbrower控件里的web程序如何调用winform里的方法。?
有demo最好了。

谢谢各位,急求

------解决方案--------------------
探讨
webbrower控件里的web程序如何调用winform里的方法。?

------解决方案--------------------
楼上正解,其实winfrom中调用webbrower他是,用的html标签跟实际web开放中的很类似,只是要遵循winfrom的调用而已。
------解决方案--------------------
C# code
 public Form27()
        {
            InitializeComponent();
            this.webBrowser1.Navigate("http://localhost:9584/");
            this.webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
        }

        void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            //throw new NotImplementedException();

            System.Windows.Forms.HtmlDocument HTMLDocument = this.webBrowser1.Document;
            System.Windows.Forms.HtmlElement closeBtn = HTMLDocument.GetElementById("ctl00$MainContent$btnClick"); //html中元素标签
            closeBtn.MouseDown += new HtmlElementEventHandler(closeWindw);// // HTML点击按钮
        }

        void closeWindw(object o, EventArgs  e)
        {
            this.WindowState = FormWindowState.Minimized;
        }

------解决方案--------------------
http://blog.csdn.net/zzzzzzzert/article/details/7787481