We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Firing an Event

KABarrie
KABarrie asked
on
Medium Priority
354 Views
Last Modified: 2012-06-21
Hello
I want to fire a custom event from my webbrowser_documentCompleted event.

the webbrowser is held in my Form1 partial class.

Code of documentcompleted event -

                    webBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(ScrapeScreen);

                    webBrowser.Navigate(buildURL.ToString());

private void ScrapeScreen(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url.AbsolutePath == (sender as WebBrowser).Url.AbsolutePath)
            {
                if (webBrowser.Document != null)
                {
                    HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                    doc.LoadHtml(webBrowser.Document.Body.InnerHtml.ToString());

                    int ranking = ScreenScrape.GetScrapeRanking(txtURL.Text, doc);

                    if (ranking > 0)
                    {
                        txtScrapeRanking.Text = ranking.ToString();
                    }
                    else
                    {
                        want to fire my event here!!!!
                    }
                }
            }
        }

Never done custom events so can someone point me to some help.  Thanks.

Kevin
Comment
Watch Question

CERTIFIED EXPERT

Commented:
 else
                    {
                      if(yourCustomEvent != null)
                            yourCustomEvent.Invoke(yourParametersIfAny);
                    }

Author

Commented:

Thanks

Can you point me somewhere that shows me how to define the event?

KEv.
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015

Commented:
@p_davis

Sorry. I guess I type too slow  = )
CERTIFIED EXPERT

Commented:
not a problem kaufmed -- thanks for the nod

Author

Commented:
Thanks guys!

Author

Commented:
Thanks Again!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.