c# - Moving textboxes within a panel with drag and drop and reorganising them while moving -


i have been searching no answers yet found problem been. if there answer sorry didn't find it. please point me, thanks.

i have panel (size: 350*60) within form. in panel have got 5 textbox (size each: 70*60). want able perform drag , drop operation (or mouseevents) of elements within panel (if cursor go out panel, textbox stays on panel) horizontally only. if take textbox 1 , want leave in 3rd position, textbox2 , 3 move 1 position left. if want move number 5 2nd position, textbox2,3,4 move 1 position right.

i want similar bar @ bottom of windows, can take controls , move them around bar.

if can me, continue found answer if find post here.

i using winform, visual studio, c# make .dll dynamic nav controladdin.

thanks knows how , others well.

good day

i posting code, can understanding it, can me:

region drag , drop

    // tengo que probar lo escrito en la libreta, con posinicial, poscruce, areapermitida, isdragging, sueltaboton     textbox tbinitial = new textbox();//tb ou je rentre     textbox tbfinal = new textbox();//tb ou je laisse     color colorprimaire = new color();//pour changer la couleur de rentrage au textbox     boolean _mousedown = false; //si c'est appuyé     point _mousedownpos; // position l'appuillage du mouse     point tbposinitial, tbposfinal;// position l'appuillage et au laissage des tb     rectangle tbrectinitial, tbrectfinal; // rectangle des tb initial et final     // commence le drag , drop en lui passant le control est proprietées et les types d'effect     private void tb_mousedown(object sender, mouseeventargs e)     {         if (e.button == mousebuttons.left)         {             colorprimaire = tb.backcolor;             tbinitial = (sender textbox);             tbposinitial = tbinitial.location;             _mousedown = true;             _mousedownpos = e.location;             tbinitial.bringtofront();             tbrectinitial = tbinitial.displayrectangle;             tbinitial.dragenter += new drageventhandler(tbinitial_dragenter);         }     }      private void tbinitial_dragenter(object sender, drageventargs e)     {         if (_mousedown)//pour pouvoir bouger horizontalement         {             point pospremiere = new point(70, 0);             point posultime = new point(nroles * 70, 0);             int deltax = e.x - _mousedownpos.x;             int deltay = e.y - _mousedownpos.y;              tbinitial.location = new point(tb.left + deltax, tb.top /* + deltay */);             tbinitial.backcolor = color.cornflowerblue;             tbfinal = (sender textbox);             tbposfinal = tbfinal.location;             tbrectfinal = tbfinal.displayrectangle;              int numrolinicial = tbposinitial.x / 70;             int numrolfinal = tbposfinal.x / 70;             //pour commencer le drag                             tbinitial.dodragdrop(tbinitial, dragdropeffects.move);             //pour faire bouger les textbox, je dois lui dire que tout les tb tbinitial jusqu'a tbfinal doivent bouger + ou - une position             tbinitial.allowdrop = true;             //pour gerer le drop et le leave et le enter sur le tbfinal             tbfinal.dragenter += new drageventhandler(tbfinal_dragenter);             tbfinal.dragdrop += new drageventhandler(tbfinal_dragdrop);             tbfinal.dragleave += new eventhandler(tbfinal_dragleave);             //pour ne pas pouvoir aller en dehors les limites             if (tbposinitial.x < pospremiere.x)             {                 tbposfinal = pospremiere;             }              if (tbposinitial.x > posultime.x)             {                 tbposfinal = posultime;             }         }     }      private void tbfinal_dragenter(object sender, drageventargs e)     {         e.effect = dragdropeffects.move;     }      private void tbfinal_dragdrop(object sender, drageventargs e)     {         _mousedown = false;         messagebox.show("tbinitial location:" + tbposinitial.tostring());//me da la posicion del raton en el textbox         messagebox.show("tbfinal location:" + tbposfinal.tostring());//me da la posicion final del textbox          eventcontroladdin(3, tbinitial.name.padright(10) + ";" + (string)tbfinal.name);          if (colorprimaire == color.bisque)         {             tb.backcolor = color.bisque;         }         else         {             tb.backcolor = color.gray;         }      }      private void tbfinal_dragleave(object sender, eventargs e)     {         //je dois recommencer tous.         tb = tbfinal;         tb.mousedown += new mouseeventhandler(tb_mousedown);     }      private void tb_mousemove(object sender, mouseeventargs e)     {         if (_mousedown)//pour pouvoir bouger horizontalement         {             point pospremiere = new point(70, 0);             point posultime = new point(mainpanel.controls.count * 70, 0);             int deltax = e.x - _mousedownpos.x;             int deltay = e.y - _mousedownpos.y;              tbinitial.location = new point(tb.left + deltax, tb.top /* + deltay */);             tbinitial.backcolor = color.cornflowerblue;             tbfinal = (sender textbox);             tbposfinal = tbfinal.location;             tbrectfinal = tbfinal.displayrectangle;              int numrolinicial = tbposinitial.x / 70;             int numrolfinal = tbposfinal.x / 70;             //pour faire bouger les textbox, je dois lui dire que tout les tb tbinitial jusqu'a tbfinal doivent bouger + ou - une position                              //pour ne pas pouvoir aller en dehors les limites             if (tbinitial.location.x < pospremiere.x)             {                 tbposfinal = pospremiere;             }              if (tbinitial.location.x > posultime.x)             {                 tbposfinal = posultime;             }         }     }       private void tb_mouseup(object sender, mouseeventargs e)     {         _mousedown = false;         messagebox.show("tbinitial location:" + tbposinitial.tostring());//me da la posicion del raton en el textbox         messagebox.show("tbfinal location:" + tbposfinal.tostring());//me da la posicion final del textbox          eventcontroladdin(3, tbinitial.name.padright(10) + ";" + (string)tbfinal.name);          if (colorprimaire == color.bisque)         {             tb.backcolor = color.bisque;         }         else         {             tb.backcolor = color.gray;         }     } 

endregion


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -