نمایش نتایج 1 تا 13 از 13

نام تاپیک: Drag Drop در Tree View

  1. #1

    Question Drag Drop در Tree View

    باسلام خدمت دوستان عزیز
    چگونه میتوان در Tree View نود ها یا زیر شاخه ها را به نود یا زیر شاخه دیگر در همان Drag Drop ، Tree View کرد ؟

  2. #2
    چرا کسی به این سوال جواب نمیده ؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟

  3. #3
    خیلی عجیبه ؟
    یعنی هیچ کس بلد نیست ؟؟؟؟؟؟؟؟؟؟

  4. #4
    بابا کسی چرا حتی به این تاپیک نگاه هم نمیکنه ؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟ ؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟ ؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟ ؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟ ؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟ ؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟ ؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟ ؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟ ؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟

  5. #5

  6. #6
    چرا کسی کمک نمیکنه ؟

  7. #7
    کاربر دائمی
    تاریخ عضویت
    بهمن 1381
    محل زندگی
    Iran
    پست
    136
    به جای این همه پست میتونی یه سری به MSDN بزنی
    توی اون یه مثال هست برای این کار

  8. #8
            private void treeView1_ItemDrag(object sender, ItemDragEventArgs e)
    {
    // Move the dragged node when the left mouse button is used.
    if (e.Button == MouseButtons.Left)
    {
    DoDragDrop(e.Item, DragDropEffects.Move);
    }
    // Copy the dragged node when the right mouse button is used.
    else if (e.Button == MouseButtons.Right)
    {
    DoDragDrop(e.Item, DragDropEffects.Copy);
    }
    }
    // Set the target drop effect to the effect
    // specified in the ItemDrag event handler.

    private void treeView1_DragEnter(object sender, DragEventArgs e)
    {
    e.Effect = e.AllowedEffect;
    }

    private void treeView1_DragOver(object sender, DragEventArgs e)
    {
    // Retrieve the client coordinates of the mouse position.
    Point targetPoint = treeView1.PointToClient(new Point(e.X, e.Y));

    // Select the node at the mouse position.
    treeView1.SelectedNode = treeView1.GetNodeAt(targetPoint);
    }

    private void treeView1_DragDrop(object sender, DragEventArgs e)
    {
    // Retrieve the client coordinates of the drop location.
    Point targetPoint = treeView1.PointToClient(new Point(e.X, e.Y));

    // Retrieve the node at the drop location.
    TreeNode targetNode = treeView1.GetNodeAt(targetPoint);

    // Retrieve the node that was dragged.
    TreeNode draggedNode = (TreeNode)e.Data.GetData(typeof(TreeNode));

    // Confirm that the node at the drop location is not
    // the dragged node or a descendant of the dragged node.
    if (!draggedNode.Equals(targetNode) && !ContainsNode(draggedNode, targetNode))
    {
    // If it is a move operation, remove the node from its current
    // location and add it to the node at the drop location.
    if (e.Effect == DragDropEffects.Move)
    {
    draggedNode.Remove();
    targetNode.Nodes.Add(draggedNode);
    }

    // If it is a copy operation, clone the dragged node
    // and add it to the node at the drop location.
    else if (e.Effect == DragDropEffects.Copy)
    {
    targetNode.Nodes.Add((TreeNode)draggedNode.Clone() );
    }

    // Expand the node at the location
    // to show the dropped node.
    targetNode.Expand();
    }
    }
    // Determine whether one node is a parent
    // or ancestor of a second node.
    private bool ContainsNode(TreeNode node1, TreeNode node2)
    {
    // Check the parent node of the second node.
    if (node2.Parent == null) return false;
    if (node2.Parent.Equals(node1)) return true;

    // If the parent node is not null or equal to the first node,
    // call the ContainsNode method recursively using the parent of
    // the second node.
    return ContainsNode(node1, node2.Parent);
    }

  9. #9
    کاربر دائمی
    تاریخ عضویت
    بهمن 1381
    محل زندگی
    Iran
    پست
    136
    خوشحالم که مشکلت حل شد

  10. #10
    سلام دوست عزیز RezaJP
    هنوز هم مشکلم کاملاً حل نشده .
    1. مشکل در به هم ریختن عکس های نود ها وقتی روی آنها کلیک میکنی که یه تاپیک زدم ولی هنوز کسی جوابی نداده .
    2. با روش Drag Drop با لا نمیتوان جای نود فرزند و پدر ( والد ) را عوض کرد .

  11. #11
    کاربر دائمی
    تاریخ عضویت
    بهمن 1381
    محل زندگی
    Iran
    پست
    136
    خوب تو کدت چک کردی که اگه فرزند نباشه ...
    اون رو اصلاح کن
    if (!draggedNode.Equals(targetNode) && !ContainsNode(draggedNode, targetNode))

  12. #12
    کاربر دائمی
    تاریخ عضویت
    بهمن 1381
    محل زندگی
    Iran
    پست
    136
    البته باید بچه های دیگه (برادراش) رو بعدا Add کنی هاااااا

  13. #13
    مرسی امتحان میکنم
    ضمناًً باز هم ممنون که اینقدر زود جواب دادی

تاپیک های مشابه

  1. عمل Drag And Drop بین کنترلهای ایجاد شده توسط برنامه
    نوشته شده توسط RK977877 در بخش برنامه نویسی در Delphi
    پاسخ: 9
    آخرین پست: سه شنبه 01 آبان 1386, 03:19 صبح
  2. کشیدن و رها کردن (Drag and Drop)
    نوشته شده توسط vb2005 در بخش برنامه نویسی در 6 VB
    پاسخ: 4
    آخرین پست: پنج شنبه 17 خرداد 1386, 21:57 عصر
  3. Drag & Drop
    نوشته شده توسط hosseinab در بخش VB.NET
    پاسخ: 4
    آخرین پست: یک شنبه 19 مهر 1383, 08:58 صبح
  4. Drag & Drop ؟
    نوشته شده توسط aliasghar در بخش برنامه نویسی در Delphi
    پاسخ: 4
    آخرین پست: دوشنبه 07 اردیبهشت 1383, 01:57 صبح

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •