Note that there are some explanatory texts on larger screens.

plurals
  1. PODesign-Time drag and drop
    primarykey
    data
    text
    <p>I'm currently working of a project where my part is to design a Design Surface where the end user can add/remove/move controls at run-time.</p> <p>I followed this tutorial <a href="https://web.archive.org/web/20090310133636/http://www.divil.co.uk/net/articles/designers/hosting.asp" rel="nofollow noreferrer">"Hosting Windows Forms Designers, by Tim Dawson"</a>, and almost have implemented all the features I need.</p> <p><strong><em>Short story for those who don't want to read the tutorial :</em></strong> I implemented <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.design.idesignerhost%28VS.85%29.aspx" rel="nofollow noreferrer"><code>IDesignerHost</code></a>, <a href="http://IContainer" rel="nofollow noreferrer"><code>IContainer</code></a>, <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.design.iselectionservice.aspx" rel="nofollow noreferrer"><code>ISelectionService</code></a>, <a href="http://msdn.microsoft.com/en-us/library/system.drawing.design.itoolboxservice%28VS.85%29.aspx" rel="nofollow noreferrer"><code>IToolboxService</code></a> and some other interface, to create my design surface. I didn't use the <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.design.designsurface%28VS.85%29.aspx" rel="nofollow noreferrer"><code>System.ComponentModel.Design.DesignSurface</code></a> already in the framework, mainly beacause I need a really custom design surface.</p> <h2>Question :</h2> <p>I want to allow user to drag &amp; drop new <code>Control</code> from the <code>IToolboxService</code> to the <code>IDesignerHost/IContainer</code>. In this tutorial, you clic on a <code>Control</code> in the toolbox, the click on the design surface to add the control.</p> <h2>What i've found :</h2> <ul> <li>There is a built-in feature that automagically does drag &amp; drop from <code>IToolboxService</code> to <code>System.ComponentModel.Design.DesignSurface</code> but it is clearly not working if you implement IDesignerHost from nothing.</li> <li><p>When you use the <code>Control.DoDragDrop(ToolboxItem)</code> method, to initiate a drag &amp; drop :</p> <ol> <li><code>IToolboxService.SerializeToolboxItem(ToolboxItem)</code> is called to serialize the item </li> <li><code>IToolboxService.IsToolboxItem(object)</code> and<br> <code>IToolboxService.IsSupported(object)</code> are called to evaluate if the<br> serialized ToolboxItem can be allowed to be droped on the design surface</li> <li>When you drop the control : <code>IToolboxService.DeserializeToolboxItem(object serializedObject)</code> is called by the design surface to deserialize the controldropped.</li> </ol></li> <li><p><code>IToolboxService.SetCursor()</code> is called to know if you define a custom cursor, or let the standard windows cursor.</p></li> </ul> <h2>Problem :</h2> <p>I implemented all mentionned above, in the "What i've found", but the drag &amp; drop is buggy : </p> <ul> <li>I drag, everything's fine, but when hovering the design surface, my cursor blink a little between standard cursor and the "<code>DragDropEffects.Copy</code>" style.</li> <li>When I drop, nothing happens, and when my cursor leave the design surface (after I dropped), then the new <code>Control</code> is created and added where I dropped it.</li> </ul> <p>Has anyone ever tried to do what I'm doing, and if so, how did you manage it ? Is there anyone that has any pointer/link/good advices ?</p> <p>Thank you =)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload