2011-04-18 60 views
0

當我在ChildWindow中使用RadTreeView時,即使將IsDragDropEnabled屬性設置爲「True」,我也無法拖動這些項目。但是當我在UserControl中使用RadTreeView時,它可以拖動。Telerik RadTreeView拖動

什麼問題,我該如何解決?

+0

您使用哪種RadTreeView? ASP.NET,WPF,Silverlight或WinForms? – 2011-04-19 06:22:44

回答

0

你不得不解僱事件

在構造器

this.treeView1.AddHandler(RadDragAndDropManager.DropQueryEvent, new EventHandler<DragDropQueryEventArgs>(OnDropQuery), true); 

然後

private void OnDropQuery(object sender, DragDropQueryEventArgs e) 
    { 
     RadTreeViewItem destinationItem = e.Options.Destination as RadTreeViewItem; 
     object source = this.GetItemFromPayload<object>(e.Options.Payload); 
     object target = destinationItem != null ? destinationItem.Item : null; 
     DropPosition position = destinationItem != null ? destinationItem.DropPosition : DropPosition.Inside; 

     if (source != null && target != null) 
     { 
      Section sourceSection = source as Section; 
      Section targetSection = target as Section; 
      Question sourceQuestion = source as Question; 
      Question targetQuestion = target as Question; 

      if (sourceQuestion != null) 
      { 
       try 
       { 

        if (sourceQuestion != null && targetQuestion != null && object.ReferenceEquals(sourceQuestion, targetQuestion)) 
        { 
         sourceSection.Questions.Remove(sourceQuestion); 
         targetSection.Questions.Add(sourceQuestion); 
         e.QueryResult = false; 
         return; 
        } 

        if (targetQuestion != null && position == DropPosition.Inside) 
        { 
         sourceSection.Questions.Remove(sourceQuestion); 
         targetSection.Questions.Add(sourceQuestion); 
         e.QueryResult = false; 
         return; 
        } 

        if (position != DropPosition.Inside && targetQuestion == null) 
        { 
         sourceSection.Questions.Remove(sourceQuestion); 
         targetSection.Questions.Add(sourceQuestion); 
         e.QueryResult = false; 
         return; 
        } 
       } 
       catch (Exception ex) 
       { 


       } 
      } 
     } 
     else 
     { 
      e.QueryResult = false; 
      return; 
     } 
     e.QueryResult = true; 

    } 

這是它。

相關問題