Parent UserControl's Properties in a UserControl (placed on another UserControl) 
Author Message
 Parent UserControl's Properties in a UserControl (placed on another UserControl)

When you place a usercontrol on a usercontrol
(instead of a form), in the childUsercontrol's code,
     Parent.<Anyproperty>
or even
     Extender.Parent.<AnyProperty>
bombs out.
     "no such property or method".

But the BEST part is on the de{*filter*} watch window
when you type Parent, you can see all of its
property under it with correct Values. For example
say Name, Controls etc. But when you type
Parent.<theProperty> (e.g. Parent.Name) it says
boms.

If the usercontrol is on a form the Parent.Name
returns the form's Name . But bombs instead of
returning the parentusercontrol's name when you
place the same control on another usercontrol.

SOS!!! Any ideas? Please Save my life?

Sujata.



Thu, 20 Nov 2003 10:49:25 GMT  
 Parent UserControl's Properties in a UserControl (placed on another UserControl)
Hi Sujata:

Quote:
> If the usercontrol is on a form the Parent.Name
> returns the form's Name . But bombs instead of
> returning the parentusercontrol's name when you
> place the same control on another usercontrol.

Try exposing the Parent object, i.e.

'Main usercontrol
Public Property Get Parent() As Object
   Set Parent = UserControl.Parent
End Property

'Child usercontrol

Private Sub UserControl_Click()
   Debug.Print Parent.Parent.Name
End Sub

Hope this helps,

Doug.



Fri, 21 Nov 2003 00:03:07 GMT  
 Parent UserControl's Properties in a UserControl (placed on another UserControl)
Doug,

U r a life saver!

I think this is working. I tried it out in a small
dummy project. I exposed the parent usercontrol's
properties and it is working now.

I will try it out in my real usercontrol today. I can
only hope no other problems crop up.

BTW, In MSDN Help I also searched on "exposing"
and found the following:

"By default, the properties of the UserControl
object - and the constituent controls you add
to it - are not visible to the end user of your
control"

Thanks a lot again!

Sujata.


Quote:
> Hi Sujata:

> > If the usercontrol is on a form the Parent.Name
> > returns the form's Name . But bombs instead of
> > returning the parentusercontrol's name when you
> > place the same control on another usercontrol.

> Try exposing the Parent object, i.e.

> 'Main usercontrol
> Public Property Get Parent() As Object
>    Set Parent = UserControl.Parent
> End Property

> 'Child usercontrol

> Private Sub UserControl_Click()
>    Debug.Print Parent.Parent.Name
> End Sub

> Hope this helps,

> Doug.



Fri, 21 Nov 2003 10:48:14 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. UserControl's Parent property

2. UserControl's Parent's BackColor Change?

3. UserControl's Parent's BackColor Change?

4. Setting Usercontrol (ocx) width at runtime wider than Width property of usercontrol

5. How to make the button in Usercontrol call Usercontrol's Click event

6. Property Browser - Can't see Usercontrol Properties

7. VB6 Text property of UserControl does not work with UpDown Control's buddy property

8. Can't get HWnd of real parent form since usercontrol container changes during load

9. App.Path of the Usercontrol's Parent form

10. UserControl's parent losing focus

11. App.Path of the Usercontrol's Parent form

12. Trapping KeyStrokes inside a UserControl for it's parent form

 

 
Powered by phpBB® Forum Software