I run into a strange problem (WinXP / .NET 2.0). I use a WinForm UserControl that overrides Refresh():
public override void Refresh()
{
DoSomeStuff();
base.Refresh();
}
I add this UserControl as child to another control and want to refresh all child controls:
ParentControl : UserControl
{
[...]
public ParentControl (...)
{
[...]
UserControl ChildControl = ModelEngine.MainControl; // UserControl as mentioned above
this.Controls.Add(ChildControl);
[...]
ModelEngine.MainControl.Refresh(); //#1
this.Refresh(); // #2
}
}
Calling the Refresh() method directly (#1) works fine. I expected that I can call Refresh() on the parent class (#2) and this would trigger a recursive Refresh() on all child controls (as explained in MSDN http://msdn.microsoft.com/en-us/library/system.windows.forms.control.refresh.aspx). However, the overridden Refresh() in the child control is not executed. BTW: setting ControlStyles.UserPaint to true didn't change the behaviour.
Of course I could call Refresh() directly (as in #1) or write my own recursive Refresh(). But I am wondering whether this bug is an indication of a bigger problem somewhere in my code...
So is there an obvious error in my code or is this the regular behaviour of .NET?