We have an interface called iDataControl. We have a container control that has iDataControl interface selected.
With the following code, all of the non-containers that are iDataControl’s on the window are recognized with the “isa iDataControl” code below. The container control is not recognized as an iDataControl, even though it is.
What are we doing wrong?
[code]For i As Integer = 0 To win.ControlCount-1
oControl = Win.Control(i)
If oControl isa iDataControl then
It is not possible to do what you are trying to achieve. The reason is that ContainerControl is not a subclass of Control. It is a subclass of Window. This leads to a lot of strange things:
When you create an instance of a ContainerControl in a window, the instance you get is of type EmbeddedWindowControl.
You can do this:
For i As Integer = 0 To win.ControlCount - 1
If win.Control(i) IsA EmbeddedWindowControl Then
So If oControl isa iDataControl then s not recognized because oControl will be an EmbeddedWindowControl, not a ContainerControl.
Casting the EmbeddedWindowControl to ContainerControl is impossible as they don’t belong to the same inheritance tree.
You can’t access the ContainerControl which is embedded in that EmbeddedWindowControl.
And because you can’t subclass EmbeddedWindowControl, you can not define an interface for EmbeddedWindowControl.
We tried a few more things, including casting to an EmbeddedWindowControl and nothing works. We will come up with a work around. Thanks for the help.
You have to keep your own array of container instances. It can be an array of type iDataControl, of course.