G
Guest
If I extend the WebBrowser class like this:
public class CustomWebBrowser : System.Windows.Forms.WebBrowser
{
public string myProperty()
{
return "myProperty";
}
}
and get the ControlsCollection of a Form like this:
ControlsCollection formControls = MyForm.Controls;
and iterate thru the collection like this:
foreach (Control ctl in formControls)
{
// if I am at the CustomWebBrowser control I am unable to cast like this
CustomWebBrowser browser = ctl as CustomWebBrowser;
}
In the above code the browser object is null when doing this with my
CustomWebBrowser class. However, if I just use the WebBrowser class where it
is not extended the control 'ctl' I am able to cast to a WebBrowser class.
How can I cast from the Control class to my CustomWebBrowser class? Any
ideas?
Thank you!
public class CustomWebBrowser : System.Windows.Forms.WebBrowser
{
public string myProperty()
{
return "myProperty";
}
}
and get the ControlsCollection of a Form like this:
ControlsCollection formControls = MyForm.Controls;
and iterate thru the collection like this:
foreach (Control ctl in formControls)
{
// if I am at the CustomWebBrowser control I am unable to cast like this
CustomWebBrowser browser = ctl as CustomWebBrowser;
}
In the above code the browser object is null when doing this with my
CustomWebBrowser class. However, if I just use the WebBrowser class where it
is not extended the control 'ctl' I am able to cast to a WebBrowser class.
How can I cast from the Control class to my CustomWebBrowser class? Any
ideas?
Thank you!