I am looking for a way to access the properties/methods of a child object.
I have a class (sub-classed from Canvas) that has a PagePanel control dropped on to it. The PagePanel has the Parent populated as the canvas control but I need it the other way around - I need to know within my canvas control the name of the PagePanel so that I can manipulate the PagePanel from within my Canvas control.
For i As Integer = 0 To MyWindow.ControlCount - 1
If MyWindow.Control(i) IsA PagePanel And MyWindow.Control(i).Parent = MyCanvas1 Then
childPagePanel = PagePanel(MyWindow.Control(i))
Exit
End
Next
If childPagePanel Is Nil Then
// we have an error
End
Ok. I had to change the code as it would not compile correctly.
In my sub-classed Canvas Open event I added the modified code:
[code] AssociatedPagePanel = nil
For i As Integer = 0 To Window.ControlCount - 1
If Window1.Control(i) IsA PagePanel then
dim pp As PagePanel = PagePanel(Window.Control(i))
if pp.Parent = me Then
me.AssociatedPagePanel = PagePanel(Window.Control(i))
Exit
End
End
Next
If AssociatedPagePanel Is Nil Then
// we have an error
MsgBox "No Associated PagePanel in " + CurrentMethodName
Quit
End
// all good
[/code]
My Canvas has a property called ‘AssociatedPagePanel’.