c# - Overridden Refresh() not called for child UserControl -


i run strange problem (winxp / .net 2.0). use winform usercontrol overrides refresh():

public override void refresh()     {         dosomestuff();         base.refresh();     } 

i add usercontrol child control , want refresh child controls:

parentcontrol : usercontrol {   [...]    public parentcontrol (...)   {     [...]      usercontrol childcontrol = modelengine.maincontrol; // usercontrol mentioned above     this.controls.add(childcontrol);      [...]      modelengine.maincontrol.refresh(); //#1     this.refresh(); // #2   } } 

calling refresh() method directly (#1) works fine. expected can call refresh() on parent class (#2) , trigger recursive refresh() on child controls (as explained in msdn http://msdn.microsoft.com/en-us/library/system.windows.forms.control.refresh.aspx). however, overridden refresh() in child control not executed. btw: setting controlstyles.userpaint true didn't change behaviour.

of course call refresh() directly (as in #1) or write own recursive refresh(). wondering whether bug indication of bigger problem somewhere in code...

so there obvious error in code or regular behaviour of .net?

as says in page linked:

notes inheritors

when overriding refresh in derived class, sure call base class's refresh method control , child controls invalidated , redrawn.

you must call base refresh() method explicitly. otherwise, there no way not run base method, , whole concept of overrides lost.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -