CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2000
    Posts
    49

    Determine Treeview Node

    How can I determine a node, from x y co-ordinates of the treeview control. Actually, I am making a program, which drags and Item from a list box to tree view control. It drops the text data on to the tree view control to add nodes to It. How can I specify, on which node, the user has dropped the item??

    Thanx for help in Advance.
    Good Bye .. Developers
    Waqas...


  2. #2
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Determine Treeview Node

    I believe you want to use the .Hittest method. Refer to MSDN Help for a example using a Treeview
    This simple example will display the node upon which something is dropped

    private Sub TV_DragDrop(Source as Control, x as Single, y as Single)

    Debug.print TV.HitTest(x, y)

    End Sub





    John G

  3. #3
    Join Date
    Dec 2000
    Posts
    66

    Re: Determine Treeview Node

    There is a treeview and textbox on the form, set the textbox OLEDragMode=Automatic
    set the treeview OLEDropMode=ccOLEDropManual. Run the project, input any text in the textbox
    select the characters in the textbox, drag&drop it on the root node of treeview.

    Here is the code.


    private Sub Form_Load()
    TreeView1.Nodes.Add , , , "root"
    End Sub

    private Sub TreeView1_OLEDragDrop(Data as MSComctlLib.DataObject, Effect as Long, Button as Integer, Shift as Integer, x as Single, y as Single)
    Dim tvwNode as Node
    set tvwNode = TreeView1.HitTest(x, y)
    Call TreeView1.Nodes.Add(tvwNode, tvwChild, , Data.GetData(1))
    End Sub




    //-----------------------------------------\\
    Where there's a wire , there's a way
    \\-----------------------------------------//

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured