c# - Rendering of controls in a moving panel -


i wonder why example below acts does. when click button panel moving properly, buttons in appears after panel have finished movement.

why acting way? flaw of panel, or code?

edit: also, panel seems recolor things lying behind. there way recolor components doesn't?

using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms;  namespace testmeny { public partial class form1 : form {     panel menu;     int menuspeed = 1;     boolean menuhidden = true;      public form1()     {         initializecomponent();         this.formborderstyle = formborderstyle.none;          menu = new panel();         menu.size = new size(100, 500);         menu.location = new point(-100, 0);         menu.backcolor = color.bisque;         controls.add(menu);          point loc = new point(10, 10);         (int = 0; < 3; i++)         {             button b = new button();             b.text = string.format("knapp {0}", + 1);             b.location = loc;             loc.offset(0, 50);             b.size = new size(80, 40);             menu.controls.add(b);         }     }      private void form1_load(object sender, eventargs e)     {         textbox1.text = menuspeed.tostring();     }      private void button1_click(object sender, eventargs e)     {         if(menuhidden) {             menu.bringtofront();             (int = 0; < menu.size.width; i++)             {                 menu.location = new point(menu.location.x+1, 0);                 system.threading.thread.sleep(convert.toint32(textbox1.text));             }         }         else         {             (int = 0; < menu.size.width; i++)             {                 menu.location = new point(menu.location.x - 1, 0);                 system.threading.thread.sleep(convert.toint32(textbox1.text));             }         }         menuhidden = !menuhidden;     } } } 

thanks in advance

call refresh() repaint form.

private void button1_click(object sender, eventargs e) {     if (menuhidden)     {         menu.bringtofront();         (int = 0; < menu.size.width; i++)         {             menu.location = new point(menu.location.x + 1, 0);             system.threading.thread.sleep(convert.toint32(textbox1.text));             refresh(); // <-----------------------         }     }     else     {         (int = 0; < menu.size.width; i++)         {             menu.location = new point(menu.location.x - 1, 0);             system.threading.thread.sleep(convert.toint32(textbox1.text));             refresh(); // <-----------------------         }     }     menuhidden = !menuhidden; } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -