Results 1 to 8 of 8

Thread: Tree View - Multiple Selections

  1. #1

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    Does anyone out there know how can get a tree-view to allow mutliple selections within a level (for the purpose of dragging and dropping the selected items to a new "parent")?

    For example, if I have the following structure:
    A
    -1
    -2
    -3
    B
    -4
    -5
    -6

    and I want to multi-select and drag items 4 and 5 to level A, how would I do this? (I already have single-selection drag and drop working).
    "It's cold gin time again ..."

    Check out my website here.

  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    To determine what items are selected in a tree view you need to loop through the nodes and test the "selected" attribute. Keep a list (either in an array or a collection) of those that are selected so you can perform the drag you want.

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Only listview can allow mutliselect, you may make a combination of treeview-listview and then drag the listitems to a node
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    Thanks for the responses, guys, but:
    Gen-X: I wish it was that easy, but I don't beleive multiple nodes can be the "SelectedItem".
    Kedaman: Point taken, but I was hoping to stick only with the tree-view; and was wondering if some kind of API function can be used to give it the functionality I'm looking for.
    "It's cold gin time again ..."

    Check out my website here.

  5. #5
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    Appologies... I was thinking of listview when you said it...

    Unfortunately API calls can NEVER give functionality to controls like that... the controls are already set and while you might be able to tinker with external things (or replicate things a user could do programmatically) you can't actually use an API call to "suddenly" allow a tree-view to select multiples.

    Either the control (TreeView) is programmed to allow multiple or it isn't... if an API call could make it DO multiples then the control would have been coded to do it in the first place.

    Sorry

  6. #6

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    I hear you, Gen-X. While I'm not an API guru, I do know that some VB controls are "dumbed down", and you can use API calls to take advantage of their full functionality (i.e., functionality that is not exposed by the VB properties).

    I had to use an API call (SendMessage with a "scroll" parameter) to get the TreeView to scroll during a drag and drop operation (using the technique recommended by Microsoft). This technique is somewhat involved in that the call is made within a Timer event when the MouseOver event detects that the mouse is close to either the top or bottom of the TV control.

    Anywho, I seem to recall using an app that allowed multiple selection of TreeView nodes, but it might have been a "home-grown" tree-view. I just tried to multi-select in Windows Explorer and couldn't do it. I know that this issue has been raised in other forums, but I have not seen a solution; but I have a nagging feeling that it is possible.

    Oh well, I'll continue my quest ...
    "It's cold gin time again ..."

    Check out my website here.

  7. #7
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    Exactly.

    The Scoll is a function that a user could do (ie someone with a scroller on their mouse) and so you could replicate it.

    Unfortunately you cannot replicate something that is NOT possible regardless what user controls or movements of mouse/keyboard you have.

  8. #8
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    Would you consider...

    an excellent alternative to the treeview is the on the vb-accelarator site. All source is provided and there is no royalties or anything. Better still, the code is mostly fantastic. (The stuff that is not fantastic is only excellent).

    I'll put a link to the site below. Then just search the site for treeview as there are about three modules you'll need to download.

    http://vbaccelerator.com/linktome.htm

    You have to see the demo to realise how good the control really is. I have had 0 defects using this control to date.

    I hope you take a look!

    Rwgards

    Paul Lewis

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