本文介绍了我怎样才能调用Eventhandler的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果有一个eventHandlar我将从If条件中调用它



if a have an eventHandlar shall i call it from If condition

if (instance.NavigateError += new SHDocVw.DWebBrowserEvents2_NavigateErrorEventHandler(instance_NavigateError))





但是它无法正常工作,实际上我是否需要得到回复是否接听?



如果你有帮助请帮忙任何其他想法。









but its not working, actually i need to get response whether its calling or not?

please help if u have any other idea.



private void button6_Click(object sender, EventArgs e)
        {



            SHDocVw.WebBrowser instance = (SHDocVw.WebBrowser)webBrowser1.ActiveXInstance;
            webBrowser1.Navigate("http://www.g4ogle.com/");


            instance.NavigateError += new SHDocVw.DWebBrowserEvents2_NavigateErrorEventHandler(instance_NavigateError);
            string asj = instance.StatusBar.GetType().ToString();




        }
        void instance_NavigateError(object pDisp, ref object URL, ref object Frame, ref object StatusCode, ref bool Cancel)
        {

            string filename = textBox1.Text;

            string fileName = filename.Substring(0, filename.LastIndexOf((".")));
            fileName += ".txt";
            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
            //  string asg = Ret[0].ToString();
            int name = Convert.ToInt32(StatusCode);
            //ret1.Add("----" + "The URL '" + url + "' is Not valid.");
            // MessageBox.Show("error on page");

            Ret.Add("----" + "The URL '" + URL + "' is Not valid.");
            //File.AppendAllLines(fileName, Ret);
            MessageBox.Show("Completed......", "Info Box", MessageBoxButtons.OK, MessageBoxIcon.Information);



        }

推荐答案



这篇关于我怎样才能调用Eventhandler的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 05:09
查看更多