Changing properties on child controls when the parent's property changes...

Changing properties on child controls when the parent's property changes...

Post by Tim Overba » Fri, 31 Jan 2003 04:29:49



Hi all,

I've got a control that contains some child controls. When the Font property
of the parent control changes, I'd like it to propogate down to the child
controls. I overrode the OnFontChanged event in my parent control to look
like this:

    Protected Overrides Sub OnFontChanged(ByVal e As System.EventArgs)
        Dim c As Control

        For Each c In Me.Controls
            c.Font = Mybase.Font
        Next
        MyBase.OnFontChanged(e)
    End Sub

It doesn't seem to work in design-time or run-time. What am I doing wrong?

Thanks,

Tim

 
 
 

Changing properties on child controls when the parent's property changes...

Post by Bharat Patel [MSF » Sat, 01 Feb 2003 07:22:48


Hi Tim,

It seems to me that this code you have is in the Usercontrol class
(Parentcotnrol). If this is the case, then you need to use
Me.Font instead of Mybase.Font .

Hope this helps!
Bharat Patel
Microsoft, Visual Basic .NET

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only. Thanks.              

 
 
 

Changing properties on child controls when the parent's property changes...

Post by Tim Overba » Sun, 02 Feb 2003 03:13:38


Hi Bharat,

Thanks for the reply. Actually, the problem turned out to be that the child
controls weren't being added to the parent control's control collection. I
changed the parent control to inherit from ContainerControl instead of
control and it works just fine.

Regards,

T



Quote:> Hi Tim,

> It seems to me that this code you have is in the Usercontrol class
> (Parentcotnrol). If this is the case, then you need to use
> Me.Font instead of Mybase.Font .

> Hope this helps!
> Bharat Patel
> Microsoft, Visual Basic .NET

> This posting is provided "AS IS" with no warranties, and confers no
rights.
> Please reply to newsgroups only. Thanks.

 
 
 

1. Child Controls disappear when changing properties of parent control

I know I'm missing something here.
I've created a custom Web Control and I am trying to create child
controls in it. When I create child controls in it (I know of the
whole ReadWriteControlDesigner issue, so all child controls are
created on the html side) the design view renders ok. But when I click
on the custom control, change a property and go back to the html view,
the child controls have disappeared! Only the custom control's opening
and closing tags remain. The weird thing is that the design view still
shows the child controls (since I RenderChildControls() in the custom
controls Render method).

I have the PersistChildren(true) tag at the top of the custom control,
and I call EnsureChildControls() in all of the get/set methods and at
the beginning of the Render method.

What am I missing?

Thanks

2. ORA 1556 maximum nuber of 99 extents allowed

3. dropdownlist onchange event to change other controls' properties within the same row in datagrid.

4. HP 100LX & Bar Code Reader

5. changing parent form properties

6. Multiple folders as one virtual folder?

7. How: Changing the look of the 'Invalid Property Value' warning in a PropertyGrid?

8. SUN growth up

9. changing a .net component's property's browsable attribute...

10. Changing Existing Property Items and Adding New Property Items

11. How to change default property editor for certain property?

12. possible to change the designer when property changed?