Ticket T187207
Visible to All Users

Drag and drop items in LayoutControl

created 10 years ago

I am trying to find a good example with source code that demonstrates how to use the drag and drop functionality with a layout control for Winforms. I would like to use a list or tree of items that when dragged and dropped on a layout control they create a new row with simply a name and a button for custom properties. I also want to be able to move the items in the layout controls in order to change the order.

This should behave in a similar manner to the Drag Drop example within the Demo Centre. Unfortunately I haven't found the source code for that example or an explanation as to how it works in the documentation. Could someone point out where I can find more information on this subject?

Thanks

Answers approved by DevExpress Support

created 10 years ago (modified 10 years ago)

Hi,
The LayoutControl provides items list and drag and drop functionality out of the box in the customization mode. See the attached sample and video for more details and let me know if this meets your requirements, or clarify if your task is different.

    Show previous comments (1)
    DevExpress Support Team 10 years ago

      Hello Dimitris,
      It seems that you are talking about Design-Time Layout Templates. If you need such a functionality at runtime, it's better to create corresponding UserControls, add them at design time as Layout Items and set the BaseLayoutItem.Visibility property to OnlyInCustomization. In this case, you will be able to drag items to the layout control from the Customization Form.
      I hope that you will find this information useful. Please let us know if you need further assistance.

        Thanks for the reply but I don't want to use the customization form. As I mentioned above I want to use a treelist since the components I will be dragging and dropping to the layout control will belong to a hierarchy which the customization form cannot do. How can I achieve that and have you got a working example that I can look into?

        DevExpress Support Team 10 years ago

          Hello Dimitris,
          Thank you for the clarification. Now I understand your scenario. In this case, your initial thoughts were correct - you need to use the approach from the DragDrop demo. You can find the required code there: "C:\Users\Public\Documents\DevExpress Demos 14.2\Components\WinForms\CS\LayoutMainDemo\Modules\DragDropLayoutControl.cs". Thus, with this logic, you need to replace one of layout controls with your TreeList and handle its MouseDown and MouseMove events in the same manner as in the demo. Specify the relations between TreeList nodes and layout items and pass the corresponding item to the DoDragDrop method.
          Please try this solution and let me know if you need further assistance.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.