Drag from Grid and Drop in Tree list node

Posted by: saffy on 8 September 2017, 1:50 pm EST

  • Posted 8 September 2017, 1:50 pm EST

    Hi

    how can we drag row from Grid and Drop in TreeList node (in tree list node it will display one cell value).

    I am able to write drag code from 

    http://www.devexpress.com/Support/Center/KB/p/A1444.aspx

     but in Tree list control I have set AllowDrop property true. and written code

    But It is not allowing to drop.

  • Replied 8 September 2017, 1:50 pm EST

    Hello,


    This KBase article is for a different Grid control. Are you using the FarPoint Spread control? If you are not seeing a control as a drop zone even though you have AllowDrop property set, you need to make sure the DragOver event, which determines what can be dropped on the target, is coded correctly.  The DragDrop event performs the actual drop.  The DragEnter/Leave events are used by the target to allocate/free any stuff needed to handle the DragOver/Drop events.  In the events, the target receives a DragEventArgs object.  This object has an AllowedEffect property that indicates what operations are supported by the source.  The Effect property indicates what is supported by the target.  By default, Effect is None which indicates that the target can not accept the drop.  At a minimum, you need to attach to the DragOver and DragDrop events.


        spread.DragOver += new DragEventHandler(spread_DragOver);
        spread.DragDrop += new DragEventHandler(spread_DragDrop);


    In the DragOver event, you need to indicate what operations are supported on the target.  In the DragDrop event, you need to process the dropped data.  For example, if the target supports a Copy operation of text data then the event handlers might look something like...


        private void spread_DragOver(object source, DragEventArgs e)
        {
            if ((e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy)
            {
                if (e.Data.GetDataPresent(DataFormats.Text))
                {
                    e.Effect = DragDropEffects.Copy;
                }
            }
        }


        private void spread_DragDrop(object source, DragEventArgs e)
        {
            string s = e.Data.GetData(DataFormats.Text).ToString();
            ... // do something with s
        }


    You can also look at the following thread for sample draging a row from one Spread to another.

  • Replied 8 September 2017, 1:50 pm EST

    Thank you for your reply.

    It helps me.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels