Telerik RadTreeView 拖动

发布于 2024-11-02 04:00:06 字数 214 浏览 1 评论 0原文

当我在 ChildWindow 中使用 RadTreeView 时,即使我将 IsDragDropEnabled 属性设置为“True”,我也无法拖动项目。但是当我在 UserControl 中使用 RadTreeView 时,它可以拖动。

问题是什么?我该如何解决?

When I use the RadTreeView in ChildWindow, even though I set the IsDragDropEnabled property to "True", I can't drag the items. But when I use the RadTreeView in a UserControl, it can drag.

What is the problem, and how can I fix it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

洋洋洒洒 2024-11-09 04:00:06

你必须

在构造函数中

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;

    }

就是这样。

You have to fire event

In contructor

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

Then

 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;

    }

This is it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文