I have some webBrowsers on my C# application, infact I have 10. webBrowser0, webBrowser1, webBrowser2 and so on..
Anyways, I'm performing a loop to count each screen to place a webBrowser on each screen I have, all this is done easily, but in my loop, if have something like this.
for (index = 0; index <= totalScreens; index++)
{
if (index == 0)
{
webBrowser0.Width = x;
webBrowser0.Height = x;
}
if (index == 1)
{
webBrowser1.Width = x;
webBrowser1.Height = x;
}
}
As you cansee, I'm doubling up on code quite a lot, so if I could refer to webBrowser{index} that would be perfect but that of course isn't working.
Create collection of your WebBrowsers.
List<WebBrowser> browsers = new List<WebBrowser> {webBrowser0,webBrowser1};
for (index = 0; index <= totalScreens; index++)
{
if(index < browsers.Count)
{
browsers[index].Width = x;
browsers[index].Height = x;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With