Norman - this looks like what I need, but cant quit figure out how to use it…
-Ive added your Module EmbeddedWindowControlExtensions to my project
- I have a TestControl class with Super=ContainerControl with several public computed properties that can raise a ValueChanged event
- I have a Window with a variable number of TestControls with ValueChanged event methods that call the window’s Evaluate() method.
- I want in the Evaluate() method to walk all TestControls on the window and check each their ‘CurrentState’ properies
So I guess I dont know how to wire your EmbeddedWindowControlExtensions to either the Window instance or my TestControl class definition.
Can you please point me in the right direction as to how to wire this up so I can walk all of the ContainerControls on a window access their custom propreties and/or custom methods?
Thanks
probably by walking all the controls on the window
for i as integer = 0 to self.ControlCount - 1
if control(i) isa EmbeddedWindowControl then
dim cc as containercontrol =EmbeddedWindowControl(control(i)). Container
if cc isa TestControl then
cc.DoSomeCustomMethod
end if
next
This is a WAG ( wild a_s_s_e_d gues ) based on what little i know about your project
@Norman Palardy : your method still runs through all the objects at runtime to find the CC we want in the window.
it would be so nice to have a window.containercontrols() method, just like the window.controls() one !
It would
But you do whats available and possible
There may be other ways to achieve what Richard wants - this is just one option
Thanks a lot for the help Norman
only other thing I seemed to need to add apparently is to down-cast cc to a TestControl. Otherwise compiler complains "Type “ContainerControl” has no member named “SomeCustomMethod”. If Im missing something here please let me know.
Dim sResult as string
Dim myTC as TestControl
for i as integer = 0 to self.ControlCount - 1
if control(i) isa EmbeddedWindowControl then
dim cc as containercontrol =EmbeddedWindowControl(control(i)). Container
if cc isa TestControl then
myTC = TestControl(cc) //downcast cc to specific subtype
sResult = myTC.SomeCustomMethod()
end if
end if
next
ah yeah - what I get for writing code in the forum editor