This is a migrated thread and some comments may be shown as answers.

Drag and Drop Over different elements

3 Answers 88 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Simon Allport
Top achievements
Rank 2
Simon Allport asked on 15 Jul 2010, 11:01 AM
Hi I have a canvas with diffient images in and a list box full of people. When i drag a person from the list over the images, the person is automatically dropped into the first image i come too,even before i release the left mouse button. Is there anyway of getting around this?

3 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 15 Jul 2010, 11:24 AM
Hi Simon Allport,

Can you please elaborate on the implementation of your scenario a bit more? If you can send us your custom logic for the DradDrop event handlers, we will be able to further investigate the issue. Also, if you can open a support ticket and send us a sample project reproducing the issue, we will take a look at it and help you get around the issue.

Thank you in advance.

Greetings,
Tina Stancheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Simon Allport
Top achievements
Rank 2
answered on 15 Jul 2010, 11:36 AM
Hi,
Thanks for getting back to me Below is the events for the listbox
private void lbWaitingList_OnDragQuery(object sender, DragDropQueryEventArgs e)
       {
           if (e.Options.Status == DragStatus.DragQuery)
           {
               ListBox list = new ListBox();
               list = (ListBox)e.OriginalSource;
               var waiting = (WaitingList)list.SelectedItem;
               e.QueryResult = true;
               e.Handled = true;
               
               e.Options.DragCue = waiting.Fullname;
               e.Options.ArrowCue = RadDragAndDropManager.GenerateArrowCue();
               e.Options.Payload = waiting.PatientID;
           }
           if (e.Options.Status == DragStatus.DropSourceQuery)
           {
               e.QueryResult = true;
               e.Handled = true;
           }
       }
The Image events
private void bed_OnDropQuery(object sender, DragDropQueryEventArgs e)
      {
          var destination = e.Options.Destination as Image;
            if (e.Options.Status == DragStatus.DropDestinationQuery &&
              destination != null)
          {
                
              e.QueryResult = true;
              e.Handled = true;
          }
      }
private void bed_OnDropInfo(object sender, DragDropEventArgs e)
      {
        
          var destination = e.Options.Destination as Image;
                        txtblkBedSelect.Text = "";
                  int patientid;
                  int apc;
                  int timestamp;
                  string hospital;
                  string listtype;
                  string z = e.Options.Payload.ToString();
                  if (z.Contains("Bed"))
                  {
                      z = z.Replace("Bed", "");
                      z = z.Replace("__", "/");
                      string[] into = z.Split('_');
                     patientid = Convert.ToInt32(into[1]);
                      apc = Convert.ToInt32(into[2]);
                      timestamp = Convert.ToInt32(into[3]);
                      hospital = Convert.ToString(into[4]);
                      listtype = Convert.ToString(into[5]);
                  }
                  else
                  {
                      z = z.Replace("System.Windows.Controls.ListBoxItem:", "");
                      z = z.Replace("__", "/");
                      string[] into = z.Split('#');
                      patientid = Convert.ToInt32(into[0]);
                      apc = Convert.ToInt32(into[1]);
                      timestamp = Convert.ToInt32(into[2]);
                      hospital = Convert.ToString(into[3]);
                      listtype = Convert.ToString(into[4]);
                  }
                  // Gets the bed number that has been selected
                  Image bed = sender as Image;
                  string x = bed.Name.ToString();
                  x = x.Replace("Bed", "");
                  int bednumber = Convert.ToInt32(x.Trim());
                  if (listtype == "T")
                  {
                      var item = (WardList)cbTransferPatientWard.SelectedItem;
                      Transfer transfer = new Transfer();
                      transfer.TransferPatient(patientid, apc, timestamp, _wardcode, Convert.ToString(item.WardCode), hospital, txtblkUsername.Text, txtblkPassword.Text);
                      Wards wards = new Wards();
                      wards.MovePatientFromOtherWard(apc, bednumber, timestamp, _wardcode, txtblkUsername.Text, txtblkPassword.Text);
                      LoadExternalWaitingList();
                  }
                  else
                  {
                      Wards wards = new Wards();
                      wards.AddPatientToBed(bednumber, patientid, apc, timestamp, txtblkUsername.Text, txtblkPassword.Text);
                      LoadExternalWaitingList();
                  }
                  waitinglist("w");
                  DataLoad();
     }
0
Simon Allport
Top achievements
Rank 2
answered on 15 Jul 2010, 01:45 PM
Hi, I solved the problem, i was missing  following statement
if (e.Options.Status == DragStatus.DropComplete && destination != null)
{
  
}
Tags
DragAndDrop
Asked by
Simon Allport
Top achievements
Rank 2
Answers by
Tina Stancheva
Telerik team
Simon Allport
Top achievements
Rank 2
Share this question
or