c# - How can I make images drag and drop-able to reorder them? -


i'm building application in i'd user able reorder pictures in form in 2 columns. i've got flowlayoutpanel of set width, , pictures added via openfiledialog , scaled half width (minus allowance scroll bar) of flow layout panel.

this i'm stuck - i've tried adding images labels, buttons, , pictureboxes , can't work out how move them around. gave on labels because canselect false - although didn't know if have made difference - , moved on buttons because realised picture boxes existed. i'm open switching out controls use images need in 2 columns.

here's code have dragenter , dragdrop events:

private void flowlayoutpanel_6_cards_dragenter(object sender, drageventargs e) {     e.effect = dragdropeffects.all; } private void flowlayoutpanel_6_cards_dragdrop(object sender, drageventargs e) {     messagebox.show("dropped"); } 

how can implement this? controls should use , properties should looking @ make possible?

so @taw's comment know have add dodragdrop call mousedown event on whatever you're dragging. now-working code below (thanks this tutorial):

private void flowlayoutpanel_6_cards_dragdrop(object sender, drageventargs e) {     picturebox picture = (picturebox)e.data.getdata(typeof(picturebox));         flowlayoutpanel _source = (flowlayoutpanel)picture.parent;     flowlayoutpanel _destination = (flowlayoutpanel)sender;      if (_source != _destination)     {         //where did from?     }     else     {         point p = _destination.pointtoclient(new point(e.x, e.y));         var item = _destination.getchildatpoint(p);         int index = _destination.controls.getchildindex(item, false);         _destination.controls.setchildindex(picture, index);         _destination.invalidate();      } }  private void flowlayoutpanel_6_cards_dragenter(object sender, drageventargs e) {     e.effect = dragdropeffects.all; }  void p_mousedown(object sender, mouseeventargs e) {     picturebox p = (picturebox)sender;     p.dodragdrop(p, dragdropeffects.all); } 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -