im using this code here
to find a webbroswer newly created
but it wont find any of my broswer
not even my static one called
webbroswer1
on the other end it will find any other control
and dispose of it properly
how can i find a webbroswer by its name and remove it
heres my code
foreach (var c in this.Controls) { if (c is Control) { var x = (Control)c; if (x.Name == dispose) {
MessageBox.Show("this works");
x.Dispose(); break; }
else { bobby, this doesnt work ); break; }
} }
Loading

VulpesRank #55 · 29.2K reputationPosted May 20, 2013, 1:17 AM EDT
If you've added them to a panel, then you will need to iterate through the panel's Controls collection to find them.
david seinfeild20 reputationPosted May 20, 2013, 2:32 AM EDT
how do i go trough those using the code i displayed
VulpesRank #55 · 29.2K reputationPosted May 20, 2013, 4:54 AM EDT
You'd start the ball rolling with:
DisposeControls(this);
david seinfeild20 reputationPosted May 20, 2013, 7:05 AM EDT
foreach (var c in this.tabControl1.Controls)
the thing is i would love to change the url of the webbroswer in that specific tab
but since its in that tab i cant find it just like i couldnt find that tab at first
anyway to acces that newly created webbrowswer in that tab using that code
,
VulpesRank #55 · 29.2K reputationPosted May 20, 2013, 7:37 AM EDT
david seinfeild20 reputationPosted May 20, 2013, 8:19 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 20, 2013, 8:37 AM EDT
if (c is WebBrowser && c.Name == "webBrowser1") ((WebBrowser)c).Url = newUri(@"http://www.google.com");
david seinfeild20 reputationPosted May 20, 2013, 10:41 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 20, 2013, 11:11 AM EDT
david seinfeild20 reputationPosted May 20, 2013, 12:48 PM EDT
i tried to just go with tabControl1.TabPages.Clear();
but it keeps giving me an error about a missing instance
VulpesRank #55 · 29.2K reputationPosted May 21, 2013, 5:34 AM EDT
Are you saying that you want to dispose of all tabpages except the one on which the webbrowser control is located?
david seinfeild20 reputationPosted May 21, 2013, 6:03 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 21, 2013, 6:27 AM EDT
david seinfeild20 reputationPosted May 21, 2013, 7:28 AM EDT