Hi to all,
My situation is: Im working on a webbrowser project, i created a favorites toolbar, but i didnt know how to create the custom item that has a value and a displayname kinda property, so i asked in this forum, i got help so what i have so far its this :
This its the custom class that will contain the url and the webpage name
Okay, thats my webpageinfo class,Vb Code:
Public Class WebPageInfo Private _title As String Private _url As String Public Property Title() As String Get Return Me._title End Get Set(ByVal value As String) Me._title = value End Set End Property Public Property Url() As String Get Return Me._url End Get Set(ByVal value As String) Me._url = value End Set End Property Public Sub New(ByVal title As String, ByVal url As String) Me._title = title Me._url = url End Sub End Class
Vb Code:
Dim pageinfos As New System.ComponentModel.BindingList(Of WebPageInfo) Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.BindingSource1.DataSource = Me.pageinfos Me.ListBox1.DisplayMember = "Title" Me.ListBox1.ValueMember = "Url" Me.ListBox1.DataSource = Me.BindingSource1 End Sub
Here comes my question.
Vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.pageinfos.Add(New WebPageInfo(WebBrowser1.DocumentTitle, WebBrowser1.Url.ToString)) End Sub
In this event i would like to add the new item created just ONCE but i dont know how to, i have an idea of how it could be done, can someone give me clues on how to do this ? thanks
my idea its something like this :
it could be something like that, right ?Vb Code:
Dim n as object for each n in pageinfos Dim once as integer once=listbox1.findstring(listbox1.displaymember) if (once=-1) then Me.pageinfos.Add(New WebPageInfo(WebBrowser1.DocumentTitle, WebBrowser1.Url.ToString))
Thanks for your help




Reply With Quote