vb.net - Sharing Controls from multiple forms/classes -
i'm stuck in how share controls between 2 forms. want do: - have several forms have own function. - want bring them gather on 1 mainform.
normally creating following code:
public class form1 private sub form1_load(sender object, e eventargs) handles mybase.load dim f new form2 groupbox1.controls.add(f.get_groupbox_controls) end sub end class
this add control containing in form2.groupbox1 , adds form1.groupbox1. works fine me.
where "get_groupbox_controls" function returns form2.groupbox1
or if doesn't works display entire form2 on form1 transparancykey. (this isn't need solution, have lot of location calculating, works)
however got form has lot going on. mainform want display 1 container(groupbox) when user clicks "more setting.." has show entire form control on it.
the problem when use container.controls.add() function exception "invoke or begininvoke cannot called on control until window handle has been created " error logical because entire form isn't made yet. in order form work has update "hidden" ui controls (labels/buttons/etc)
so main question is, how can "port" selection of controls form1 form2 , keep handlers etc.. on form1
if have 2 forms want place identical looking/functioning groupbox sections, may want consider creating custom user control contains shared functionality , can placed in each form. user controls can added form through form designer in visual studio.
Comments
Post a Comment