c# - Custom Panel Control with Child-Panel Control does not display Controls in Designer -


i created custom panel consists of panel , 2 scrollbars. when try add controls on add design time, won't display them, @ runtime able see them.

this current code:

using system; using system.collections.generic; using system.linq; using system.text; using system.windows.forms; using system.componentmodel; using system.drawing;  using system.runtime.interopservices; using system.windows.forms.design;  namespace materialwinforms.controls {      [designer(typeof(parentcontroldesigner))]     public class materialpanel : control, imaterialcontrol     {         [browsable(false)]         public int depth { get; set; }         [browsable(false)]         public materialskinmanager skinmanager { { return materialskinmanager.instance; } }         [browsable(false)]         public mousestate mousestate { get; set; }          public boolean autoscroll         {                         {                 return mainpanel.autoscroll;             }             set             {                 mainpanel.autoscroll = value;                 verticalscrollbar.visible = mainpanel.verticalscroll.visible;                 verticalscrollbaradded = verticalscrollbar.visible;                 horizontalscrollbar.visible = mainpanel.horizontalscroll.visible;                 horizontalscrollbaradded = horizontalscrollbar.visible;             }         }          public new bool autosize         {                         {                 return mainpanel.autosize;             }              set             {                 mainpanel.autosize = value;                 base.autosize = value;             }         }          private materialscrollbar verticalscrollbar, horizontalscrollbar;         private boolean verticalscrollbaradded, horizontalscrollbaradded;         private materialdisplayingpanel mainpanel;          private bool ignoreresize = true;         private bool ignoremainpanelresize = false;         public override color backcolor { { return skinmanager.getcardscolor(); } }          public new controlcollection controls         {                         {                 return mainpanel.controls;             }         }          public materialpanel()         {             doublebuffered = true;             verticalscrollbar = new materialscrollbar(materialscrollorientation.vertical);             verticalscrollbar.scroll += scrolled;             verticalscrollbar.visible = false;             verticalscrollbaradded = false;              horizontalscrollbar = new materialscrollbar(materialscrollorientation.horizontal);             horizontalscrollbar.scroll += scrolled;             horizontalscrollbar.visible = false;             horizontalscrollbaradded = false;              mainpanel = new materialdisplayingpanel();             mainpanel.resize += mainpanel_resize;             mainpanel.location = new point(0, 0);              size = new size(90, 90);              base.controls.add(mainpanel);             base.controls.add(verticalscrollbar);             base.controls.add(horizontalscrollbar);             mainpanel.controladded += materialpanel_controlschanged;             mainpanel.controlremoved += materialpanel_controlschanged;             mainpanel.onscrollbarchanged += mainpanel_onscrollbarchanged;             autoscroll = true;              ignoreresize = false;         }          protected override void oncontroladded(controleventargs e)         {             base.oncontroladded(e);               verticalscrollbar.bringtofront();             horizontalscrollbar.bringtofront();              mainpanel.bringtofront();         }          void mainpanel_onscrollbarchanged(orientation pscrollorientation, bool pvisible)         {             updatescrollbars();         }          void scrolled(object sender, scrolleventargs e)         {             mainpanel.autoscrollposition = new point(horizontalscrollbar.value, verticalscrollbar.value);         }          void materialpanel_controlschanged(object sender, controleventargs e)         {             updatescrollbars();             mainpanel.bringtofront();             verticalscrollbar.bringtofront();             horizontalscrollbar.bringtofront();         }          protected override void onlayout(layouteventargs levent)         {             base.onlayout(levent);             mainpanel.bringtofront();             verticalscrollbar.bringtofront();             horizontalscrollbar.bringtofront();         }          void mainpanel_resize(object sender, eventargs e)         {             if (!ignoremainpanelresize)                 updatescrollbars();             else                 ignoremainpanelresize = false;         }           protected override void onresize(eventargs eventargs)         {             verticalscrollbar.location = new point(width - verticalscrollbar.width, 0);             verticalscrollbar.size = new size(verticalscrollbar.width, height - horizontalscrollbar.height);             verticalscrollbar.anchor = ((anchorstyles)anchorstyles.top | anchorstyles.bottom | anchorstyles.right);             horizontalscrollbar.location = new point(0, height - horizontalscrollbar.height);             horizontalscrollbar.size = new size(width - verticalscrollbar.width, horizontalscrollbar.height);             horizontalscrollbar.anchor = ((anchorstyles)anchorstyles.left | anchorstyles.bottom | anchorstyles.right);              base.onresize(eventargs);             updatescrollbars();          }           private void updatescrollbars()         {             if(ignoreresize)             {                 return;             }             verticalscrollbar.minimum = mainpanel.verticalscroll.minimum;             verticalscrollbar.maximum = mainpanel.verticalscroll.maximum;             verticalscrollbar.largechange = mainpanel.verticalscroll.largechange;             verticalscrollbar.smallchange = mainpanel.verticalscroll.smallchange;              horizontalscrollbar.minimum = mainpanel.horizontalscroll.minimum;             horizontalscrollbar.maximum = mainpanel.horizontalscroll.maximum;             horizontalscrollbar.largechange = mainpanel.horizontalscroll.largechange;             horizontalscrollbar.smallchange = mainpanel.horizontalscroll.smallchange;              if (mainpanel.verticalscroll.visible && !verticalscrollbaradded)             {                 verticalscrollbaradded = true;                 verticalscrollbar.visible = true;             }             else if (!mainpanel.verticalscroll.visible && verticalscrollbaradded)             {                 verticalscrollbaradded = false;                 verticalscrollbar.visible = false;             }             if (mainpanel.horizontalscroll.visible && !horizontalscrollbaradded)             {                 horizontalscrollbaradded = true;                 horizontalscrollbar.visible = true;             }             else if (!mainpanel.horizontalscroll.visible && horizontalscrollbaradded)             {                 horizontalscrollbaradded = false;                 horizontalscrollbar.visible = false;             }             ignoremainpanelresize = true;               size mainpanelsize = new size(width - (verticalscrollbaradded ? verticalscrollbar.width : 0), height - (horizontalscrollbaradded ? horizontalscrollbar.height : 0));              mainpanel.ignoreresizing = true;             ignoremainpanelresize = true;             mainpanel.size = new size(width - (verticalscrollbaradded ? verticalscrollbar.width : 0), height - (horizontalscrollbaradded ? horizontalscrollbar.height : 0));             mainpanel.ignoreresizing = false;             ignoremainpanelresize = false;         }         protected override void onpaint(painteventargs e)         {             e.graphics.clear(backcolor);          }     }       internal class materialdisplayingpanel : panel, imaterialcontrol     {         [browsable(false)]         public int depth { get; set; }         [browsable(false)]         public materialskinmanager skinmanager { { return materialskinmanager.instance; } }         [browsable(false)]         public mousestate mousestate { get; set; }         public override color backcolor { { return skinmanager.getapplicationbackgroundcolor(); } }          public delegate void scrollbarchanged(orientation pscrollorientation, boolean pvisible);          public bool ignoreresizing = false;          public event scrollbarchanged onscrollbarchanged;         public materialdisplayingpanel()         {             doublebuffered = true;             padding = new padding(3, 3, 3, 3);         }          protected override void onlayout(layouteventargs e)         {             base.onlayout(e);             foreach (control objcontrol in controls)             {                 objcontrol.bringtofront();             }         }          [dllimport("user32.dll")]         [return: marshalas(unmanagedtype.bool)]         private static extern bool showscrollbar(intptr hwnd, int wbar, bool bshow);          private enum scrollbardirection         {             sb_horz = 0,             sb_vert = 1,             sb_ctl = 2,             sb_both = 3         }          protected override void onresize(eventargs eventargs)         {             base.onresize(eventargs);             if (onscrollbarchanged != null)             {                 onscrollbarchanged(orientation.horizontal, horizontalscroll.visible);                 onscrollbarchanged(orientation.vertical, verticalscroll.visible);             }         }          protected override void wndproc(ref system.windows.forms.message m)         {             if (onscrollbarchanged != null && ! ignoreresizing)             {                 onscrollbarchanged(orientation.horizontal, horizontalscroll.visible);                 onscrollbarchanged(orientation.vertical, verticalscroll.visible);             }             showscrollbar(this.handle, (int)scrollbardirection.sb_horz, false);             showscrollbar(this.handle, (int)scrollbardirection.sb_vert, false);             base.wndproc(ref m);         }          protected override void onpaint(painteventargs e)         {             e.graphics.clear(backcolor);              foreach (control objchild in controls)             {                 if (typeof(ishadowedmaterialcontrol).isassignablefrom(objchild.gettype()))                 {                     ishadowedmaterialcontrol objcurrent = (ishadowedmaterialcontrol)objchild;                     drawhelper.drawshadow(e.graphics, objcurrent.shadowborder, objcurrent.elevation, skinmanager.getapplicationbackgroundcolor());                 }              }         }     } } 

what doing wrong or missing ?


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -