|
-
Dec 23rd, 2007, 08:19 AM
#1
Thread Starter
New Member
[SOLVED][2.0] WebBrowser control array
Hi,
As the title says, my question is about a webbrowser control array.
I want to fire the documentcompleted event for each wb in the array.
How can i specify its index? Should i just add the same event handler for every control? Even if this goes fine, would it be faster if i create new threads to handle them?
I hope im not saying nonsenses, im pretty new to .NET 
Thanks
Last edited by Tughack; Dec 23rd, 2007 at 09:11 AM.
-
Dec 24th, 2007, 08:21 AM
#2
Re: [SOLVED][2.0] WebBrowser control array
It's considered good form to post your solution to help others who may have the same question in future.
Code:
private WebBrowser[] browsers;
private void Form1_Load(object sender, EventArgs e)
{
this.browsers = new WebBrowser[] { this.webBrowser1, this.webBrowser2, this.webBrowser3 };
}
private void webBrowsers_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
int index = Array.IndexOf(this.browsers, sender);
MessageBox.Show(string.Format("The WebBrowser at index {0} has completed loading a document.", index));
}
You would select that method as the DocumentCompleted event handler for all three WebBrowser controls.
-
Dec 24th, 2007, 08:26 AM
#3
Thread Starter
New Member
Re: [SOLVED][2.0] WebBrowser control array
You're right,
Here's my approach, my problem was basically with the array declaration:
Code:
WebBrowser[] wbArray = new WebBrowser[5];
for (int i = 0; i < 5; i++)
{
WebBrowser wb = new WebBrowser();
wb.Name = "wb" + i;
wb.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.wb_DocumentCompleted);
wb.Navigate("www.google.com");
wbArray[i] = wb;
}
Tughack
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|