Drag and Drop between xtragrid and Scheduler

余生颓废 提交于 2019-12-13 04:23:12

问题


someone can tell me how to drag and drop data between gridcontrol and schedulercontrol from devexpress? I want to drag the data from the grid and drop it on the scheduler. The devexpress example in the demo doesnt work for me. I just get a block-symbol.

regards


回答1:


I got it.

 private void grdGrid_MouseDown(object sender, MouseEventArgs e)
        {
            posImGrid = null;

            GridHitInfo hitInfo = grvView.CalcHitInfo(new Point(e.X, e.Y));

            if (Control.ModifierKeys != Keys.None)
            {
                return;
            }

            if ((e.Button == System.Windows.Forms.MouseButtons.Left) &&
                (hitInfo.InRow) &&
                (hitInfo.HitTest != GridHitTest.RowIndicator))
            {
                posImGrid = hitInfo;
            }
        }

        private void grdGrid_MouseMove(object sender, MouseEventArgs e)
        {
            if ((e.Button == System.Windows.Forms.MouseButtons.Left) &&
                (posImGrid != null))
            {
                Size dragSize = SystemInformation.DragSize;
                Rectangle dragRect = new Rectangle(new Point(posImGrid.HitPoint.X - dragSize.Width / 2,
                                                             posImGrid.HitPoint.Y - dragSize.Height / 2), dragSize);

                if (!dragRect.Contains(new Point(e.X, e.Y)))
                {
                    grvView.GridControl.DoDragDrop(GetDragData(grvView), DragDropEffects.All);
                    posImGrid = null;
                }
            }
        }

        private SchedulerDragData GetDragData(GridView view)
    {
        Appointment termin = Storage.CreateAppointment(AppointmentType.Normal);
        clsMeineKlasse tempObjekt = (clsMeineKlasse)grvView.GetFocusedRow();
        termin.Description = tempObjekt.Beschreibung;
        termin.Subject = tempObjekt.Bezeichnung;
        termin.Duration = TimeSpan.FromHours(8);

        SchedulerDragData sdd = new SchedulerDragData(termin);

        return sdd;
    }


来源:https://stackoverflow.com/questions/14124538/drag-and-drop-between-xtragrid-and-scheduler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!