Click here to Skip to main content
15,894,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
im having a problem, for which i have scoured the internet for, but ccould not find a solution for. basically when i debug it say arguement not specified for parameters sender of private sub items_click(byval sender as system.object, byval e as system.eventargs)
this is my code
Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
        Dim b As New ToolStripButton(WebBrowser1.Url.AbsoluteUri)
        ToolStrip1.Items.Add(b)
    End Sub

    Private Sub addLink(ByVal url As [String], ByVal name As String)
        Dim myXml As New XmlDocument()
        Dim el As XmlElement = myXml.CreateElement("link")
        el.SetAttribute("url", url)
        el.InnerText = name

        If Not File.Exists(linksXml) Then
            Dim root As XmlElement = myXml.CreateElement("links")
            myXml.AppendChild(root)
            root.AppendChild(el)
        Else
            myXml.Load(linksXml)
            myXml.DocumentElement.AppendChild(el)
        End If
        If ToolStrip1.Visible = True Then
            Dim b As New ToolStripButton(el.InnerText, getFavicon(url), items_Click, el.GetAttribute("url"))
            b.ToolTipText = el.GetAttribute("url")
            ToolStrip1.Items.Add(b)
        End If

        myXml.Save(linksXml)
    End Sub

    Private Function faviconIndex(ByVal url As String) As Integer
        Dim key As New Uri(url)
        If Not imglist.Images.ContainsKey(key.Host.ToString()) Then
            imglist.Images.Add(key.Host.ToString(), favicon(url, "link.png"))
        End If
        Return imglist.Images.IndexOfKey(key.Host.ToString())
    End Function
    Private Sub items_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim b As ToolStripButton = CType(sender, ToolStripButton)
        WebBrowser1.Navigate(b.ToolTipText)
    End Sub



    Public Shared Function favicon(ByVal u As [String], ByVal file As String) As Image
        Dim url As New Uri(u)
        Dim iconurl As [String] = "http://" + url.Host & "/favicon.ico"

        Dim request As WebRequest = WebRequest.Create(iconurl)
        Try
            Dim response As WebResponse = request.GetResponse()

            Dim s As Stream = response.GetResponseStream()
            Return Image.FromStream(s)
        Catch ex As Exception
            Return Image.FromFile(file)
        End Try


    End Function

    Private Function getFavicon(ByVal key As String) As Image
        Dim url As New Uri(key)
        If Not imglist.Images.ContainsKey(url.Host.ToString()) Then
            imglist.Images.Add(url.Host.ToString(), favicon(key, "link.png"))
        End If
        Return imglist.Images(url.Host.ToString())
    End Function

    Private Sub showLinks()
        If File.Exists(linksXml) Then
            Dim myXml As New XmlDocument()
            myXml.Load(linksXml)
            Dim root As XmlElement = myXml.DocumentElement
            For Each el As XmlElement In root.ChildNodes
                Dim b As New ToolStripButton(el.InnerText, getFavicon(el.GetAttribute("url")), items_Click, el.GetAttribute("url"))
                b.ToolTipText = el.GetAttribute("url")
                ToolStrip1.Items.Add(b)
            Next
        End If
    End Sub


and this is where i think im getting my problems:
Private Sub items_Click(ByVal sender As Object, ByVal e As EventArgs)
    Dim b As ToolStripButton = CType(sender, ToolStripButton)
    WebBrowser1.Navigate(b.ToolTipText)
End Sub

btw the first block isnt all of the code, its just the main part of where im getting the problem(no problems anywhere else)
Posted

1 solution

Use AddressOf when declaring a new toolstripbutton

Try:
Dim b As New ToolStripButton(el.InnerText, getFavicon(url), AddressOf items_Click, el.GetAttribute("url"))
 
Share this answer
 
Comments
r4p3z0rz 30-Jul-10 6:37am    
thnks! it worked!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900