Web Browser Control cookies

Hey,

I am using a combobox to show the URL you are at on the webbrowser control, and I made it so that when you press the Go button it will add the Url to the Combobox list...

WebBrowser thiswebpage = GetCurrentWebBrowser();// Get the currently displayed WebBrowser

URLtextbox.Items.Add(thiswebpage.Document.Url);

But wehn I look at the combobox it has the webpage URL you were jsut at about 10 or more times in a row...So it is saving the cookies more then once, how do I fix this?

Thanks :)

[866 byte] By [progames25] at [2007-12-22]
# 1

should you not just be adding the url entered into the combobox?

this.URLtextbox.Items.Add(this.URLtextbox.Text) ?

ahmedilyas at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2

Well, I dont know becuase I was at the time jsut trying to figure it out and managed to find that worked so...ya...

Thanks :)

progames25 at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 3
ok, so now it is

URLtextbox.Items.Add(thiswebpage.Document.Url.ToString());

and it adds only one. BUT how would you make it so if it already is in the dropdown then it will not add it again?

Thanks :)

progames25 at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 4

look through the collection of objects stored in the list according to the solution I had provided you via email.

So, for each element in the array, if current element.url does not equal URLTextbox.Text, add to collection.

ahmedilyas at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 5
Ok I will.
progames25 at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 6

Hmmm, What event did you put it in the Form1.cs code? becuase I could not find it...

Well what you told me gave me an idea of what it should be like...so would this work?

if (URLtextbox.Items.Contains(URLtextbox.Text))

{

URLtextbox.Items.Add(thiswebpage.Document.Url.ToString()); //Add the URL to combobox

}

I got no errors with it so...I am assuming it would...

Thanks :)

progames25 at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 7
you are basically saying that if the urlitems combo box contains the text entered in the urltextbox then add it to the collection - thats not what you want, but the opposite :)
ahmedilyas at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 8

LOL,

ok, ya thats funny, I gotta watch what I code in more carfully, I better make it add it in else

Thanks :)

progames25 at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 9

ummm...I put it in the else statment of what I am doing but then it just does what it was doing from the start...

Thanks :)

progames25 at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms General...