Search code examples
c#awesomium

Making a function run after an awesomium event


I am fairly new to programming and I am working on a browser using the awesomium engine it is working well but I want to add a label which will list the URL of the site you are currently at I have this function to make the label update

    private void refreshurllabel()
    {
        label1.Text = webControl1.Source.ToString();
    }

But I need to use events to make this function run everytime a new page loads. Looking through awesomium documentation I found this event http://docs.awesomium.net/html/E_Awesomium_Windows_Controls_WebControl_AddressChanged.htm called AddressChangedthat would suit my needs but due to my limited knowledge I cannot work out how to make a function to run when this event is called.

Any help would be greatly appreciated.


Solution

  • You need to wire up an event handler. Somewhere in your code you need to add something like

    webControl1.AddressChanged += webControl1_AddressChanged;

    Then a function to handle the event

    void webControl1_AddressChanged(object sender, EventArgs e){
         webControl wc = (webControl)sender;
         label1.Text = wc.Source.ToString();
    }