Form of object created from another object in c# -


i have form containing flowlayoutpanel, , user control added panel. in constructor of user control a, pointer same flowlayoutpanel passed, user control creates user control b in same flowlayoutpanel. problem user control b first added, a.

form1.cs

public partial class form1 : form {     public form1()     {         initializecomponent();     }      private void addbtn_click(object sender, eventargs e)     {         flowlayoutpanel1.controls.add(new graphic1(this.flowlayoutpanel1));       } } 

graphic1.cs

public partial class graphic1 : usercontrol {     public graphic1(flowlayoutpanel flowpointer)     {         initializecomponent();          flowpointer.controls.add(new graphic2());     } } 

graphic2.cs label

problem graphic2.cs added before graphic1.cs in panel

i see 3 possible solutions:

  • if constructor of control receives flow layout panel, have control add itself flow layout panel, add additional controls.
  • instead of adding additional control in constructor of control a, add method such initializelayout control a. can invoke method after adding control flow layout panel, , method add additional controls flow layout panel.
  • capture changes parent property of control (not sure whether possible; depends on gui toolkit using) , add additional controls when parent of control has changed.

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -