How does the HTML element in webbrowser trigger the winform event?
This is a question from the Forum. If you have a little understanding of Dom, you can simply register the event.
C #CodeAs follows:
Using system;
Using system. componentmodel;
Using system. Windows. forms;
Namespace windowsapplication5
...{
Public partial class form1: Form
...{
Public form1 ()
...{
Initializecomponent ();
}
Private void form1_load (Object sender, eventargs E)
...{
This. webbrowser1.navigate ("www.google.cn ");
This. webbrowser1.documentcompleted + = new webbrowserdocumentcompletedeventhandler (webbrowser1_documentcompleted );
}
Void webbrowserappsdocumentcompleted (Object sender, webbrowserdocumentcompletedeventargs E)
...{
If (E. url. tostring ()! = This. webbrowser1.url. tostring () return;
Foreach (system. Windows. Forms. htmlelement El in this. webbrowser1.document. getelementsbytagname ("input "))
...{
If (El. Name = "btng ")
...{
El. Click + = new htmlelementeventhandler (form1_click );
}
}
}
Void form1_click (Object sender, htmlelementeventargs E)
...{
MessageBox. Show ("jinjazz pass ");
}
}
}