Ticket T728524
Visible to All Users

Example needed on drag and drop between cxgrid and treeview

created 6 years ago

Hello,

I'm trying to see how drag and drop works, but the CXGRID drag and drop demo is unusable for me. I am very, very impressed that you have created the "DragDropDemoMain" cxgrid without any Views. I don't know how you load the views into the grid and i don't really care. I care about trying to track down the mechanisms of the drag and drop, and without having a view connected to a event that's not so easy.

I also want to find out how the DataController.FocusedRecordIndex; is connected to the key of my underlying database, but that is hard because then by a lot of reverse engineering i have to somehow find out the field list from the XML document that is loaded into the clientdatasets…

In essence, i have to spend A LOT of time on reverse engineering just to understand your demos before i can get started with the drag and drop.

Som what i need is some simple demo for drag and drop between cxgrid and treview and a goodand USABLE explanation of how to IMPLEMENT the DataController.FocusedRecordIndex (not just another "explanation" that is technically correct but don't explain anything) .

Regards, Pär.

Answers approved by DevExpress Support

created 6 years ago

Hello Pär,

We do not have a simpler demo for this task. Attached is a small sample project I created to demonstrate Drag And Drop operations. I hope this example will be of help.

Here are the actions you need to perform to enable Drag And Drop in TcxGrid:

  1. Set the Grid View's DragMode property to dmAutomatic.
  2. Handle the target control's OnDragOver event to accept Drop operations.
  3. Implement the target control's OnDragDrop event to place a dropped data record into this control.
  4. Use the DataController.FocusedRecordIndex property to get any value of a focused record.

Please review the "TcxCustomGridView.DragMode" and "Implementing Drag-And-Drop Functionality" help topic and related articles for additional information.

    Comments (2)

      I was unclear. I already find some example about how to drag from a grid to a treeview. Its the other way i need. From a treeview to a cxgrid. How to identify the record involved  in both components.

        Finally i solved it. Nowhere in any demo or in any help file could i find how to get the info from the Source (when a Treeview)

        In the event …TableView1DragDrop(Sender, Source: TObject; X,
          Y: Integer);

        Var

        ANode: TcxTreeListNode;
          aNodeVar : Variant;
          treeCol : TcxDBTreeListColumn;

        Begin

        ANode := TcxDBTreeList(Source).FocusedNode;
               treeCol:=TcxDBTreeList(Source).GetColumnByFieldName('ID');
               aNodeVar:=ANode.Values[treeCol.ItemIndex];

        Well, i found thousands of lines with text for the advanced stuff i not yet need, but the very few lines i needed to get started was not there.

        Best regards, Pär

        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.