Re: WebBrowser Control - Which element was clicked
- From: "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 6 Dec 2007 11:06:02 -0500
Bill,
Well, the element that is clicked is the sender parameter, you just have
to cast it to an HTMLElement and viola.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
"Bill" <Bill@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:65F6345C-645A-41D4-BF02-CBF8B876858A@xxxxxxxxxxxxxxxx
I have a form with a WebBrowser control. In the DocumentComplete event I
add
an OnClick handler for each link found in the document. The OnClick for
each
link calls the same handler function.
The events fire and this works great. The problem I have is determining
which link was clicked.
I would like to be able to get an instance of the specific HTMLElement
object that was clicked in the handler function.
The toElement and srcElement properties of the HtmlElementEventArgs object
are always null.
I would appreciate any ideas.
private void webBrowser_DocumentCompleted(object sender,
WebBrowserDocumentCompletedEventArgs e)
{
HtmlElementCollection tags = webBrowser.Document.Links;
foreach(HtmlElement element in tags)
element.Click += new
HtmlElementEventHandler(element_Click);
}
void element_Click(object sender, HtmlElementEventArgs e)
{
HTMLElement ClickedElement = ?????
}
--
Bill
.
- Follow-Ups:
- Re: WebBrowser Control - Which element was clicked
- From: Peter Bromberg [C# MVP]
- Re: WebBrowser Control - Which element was clicked
- From: Bill
- Re: WebBrowser Control - Which element was clicked
- Prev by Date: Re: Send netowrk messgae between users
- Next by Date: Re: PropertyGrid and Custom editing/formatting
- Previous by thread: Re: Send netowrk messgae between users
- Next by thread: Re: WebBrowser Control - Which element was clicked
- Index(es):
Relevant Pages
|