在xtragrid和Scheduler之间拖放

时间:2013-01-02 15:25:41

标签: c# .net winforms devexpress

有人可以告诉我如何在devexpress的gridcontrol和schedulercontrol之间拖放数据?我想从网格中拖动数据并将其放在调度程序上。演示中的devexpress示例对我不起作用。我只是得到一个块符号。

问候

1 个答案:

答案 0 :(得分:1)

我明白了。

 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;
    }