Click here to Skip to main content
15,887,954 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
hello, could anyone tell me what i did wrong and how to fix this, here is the code.
This should be bookmarks bar in metrotoolbar (dotnetbar). If this code is completely wrong could you provide me working code?
my settings is set to System.Collections.Specialized.StringCollection
am using webkit browser

VB
'form load
If My.Settings.bukbar IsNot Nothing Then
            For Each Sl As String In My.Settings.bukbar
                Dim LinkInfo As String() = Sl.Split(",")
                Dim NewLink As New ButtonItem(LinkInfo(0))
                MetroToolbar1.Items.Add(NewLink)
                NewLink.Tag = LinkInfo(1)
                AddHandler NewLink.Click, AddressOf GoToLink

            Next
        Else
            My.Settings.bukbar = New System.Collections.Specialized.StringCollection
        End If


'add bookmark bar
If Not My.Settings.bukbar.Contains(WebBrowser1.DocumentTitle & "," & WebBrowser1.Url.ToString) Then
            Dim I As New ButtonItem
            I.Text = WebBrowser1.DocumentTitle
            I.Tag = WebBrowser1.Url.ToString
            MetroToolbar1.Items.Add(I)
            AddHandler I.Click, AddressOf GoToLink


            My.Settings.bukbar.Add(WebBrowser1.DocumentTitle & "," & WebBrowser1.Url.ToString)
        End If


 Private Sub GoToLink(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim Link As Uri = New Uri(sender.tag)
        WebBrowser1.Navigate(Link)'here is the problem, "Value of type "system.uri" cannot be converted to "string"
    End Sub
Posted
Comments
Sergey Alexandrovich Kryukov 28-Jul-14 19:45pm    
What concerns do you have, exactly. Is something going wrong?
—SA
DeadlyNoodle 28-Jul-14 19:49pm    
WebBrowser1.Navigate(Link)'here is the problem, "Value of type "system.uri" cannot be converted to "string" ; how should i remake it?
Sergey Alexandrovich Kryukov 28-Jul-14 20:15pm    
Are you using .NET prior to v.2.0?
—SA

1 solution

In all versions of .NET starting from v.2.0, this is a correct method: http://msdn.microsoft.com/en-us/library/ms161352%28v=vs.80%29.aspx[^].

If you are using some prior version of .NET, 1) migrate to any version starting from 2.0, or, better, 3.5; discontinue support of older version; actually the first decent .NET is v.2.0; 2) if you cannot do it right now, use WebBrowser1.Navigate(sender.tag).

By the way, never use auto-generated names like "WebBrowser1". Such names violate (good) Microsoft naming conventions and not designed to be used permanently. Rename all such names to some semantic names. Just "webBrowser" would be good enough.

—SA
 
Share this answer
 
Comments
Maciej Los 29-Jul-14 1:58am    
+5
Sergey Alexandrovich Kryukov 29-Jul-14 4:29am    
Thank you, Maciej.
—SA

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