Webbrowser Link Event (Open Form)

Kayot

Well-known member
Joined
Mar 6, 2007
Messages
49
Programming Experience
3-5
I've searched through the forms and found one that sort of covers this here.

I would like to know how do I get a hyperlink in a webbrowser (Control) to open another form. Assume that there are hundreds of dynamically generated links.

These links don't have urls. All I need is to get the text from what ever link was clicked. The rest will be handled via a string split and sort.

Heres what I have:
VB.NET:
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As _
Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) _
Handles txtItemDesc.DocumentCompleted
	txtItemDesc.Document.Links(0).AttachEventHandler("onclick", AddressOf LinkClick)
End Sub

Sub LinkClick(ByVal sender As Object, ByVal e As System.EventArgs)
	bCancel = True
	MsgBox(txtItemDesc.Document.Links(0).InnerText)
End Sub

Dim bCancel As Boolean = False
Private Sub WebBrowser1_Navigating(ByVal sender As Object, _
ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) _
Handles txtItemDesc.Navigating
	If bCancel = True Then
		e.Cancel = True
		bCancel = False
	End If
End Sub

txtItemDesc is the name of the webbrowser. I hope this can be done. Other wise the user will have to do leg work to get data T-T.
 
Try this one instead, attaches to all elements onclick, so you can check the ActiveElement and see if it's a link and investigate further.
 
Back
Top