Drag and Drop Over different elements

4 posts, 0 answers
  1. Simon Allport
    Simon Allport avatar
    32 posts
    Member since:
    Aug 2009

    Posted 15 Jul 2010 Link to this post

    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?
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 15 Jul 2010 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Simon Allport
    Simon Allport avatar
    32 posts
    Member since:
    Aug 2009

    Posted 15 Jul 2010 Link to this post

    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();
         }
  5. Simon Allport
    Simon Allport avatar
    32 posts
    Member since:
    Aug 2009

    Posted 15 Jul 2010 Link to this post

    Hi, I solved the problem, i was missing  following statement
    if (e.Options.Status == DragStatus.DropComplete && destination != null)
    {
      
    }
Back to Top