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

    Multi Selection on TreeView

    hi.
    any one know how to select more then one item on TreeView?

    Smile, Shmulik. (-;

  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Multi Selection on TreeView


    'This may simulate it.
    'When you need to know which were selected, you should
    'check for bacground color of each node inside a loop.
    'to multiselect, hold down shift whlie left clicking on nodes


    option Explicit
    Dim itemSelected as Boolean
    Dim lastnodeIndex as Integer
    private Sub Command1_Click()
    Dim i as Integer
    With TreeView1
    for i = 0 to 9
    .Nodes.Add , , "a" & i, "AAA" & i
    next i

    End With

    End Sub

    private Sub TreeView1_MouseDown(Button as Integer, Shift as Integer, X as Single, Y as Single)
    itemSelected = false
    If Button = vbLeftButton then
    If Shift then
    itemSelected = true
    End If
    End If
    End Sub

    private Sub TreeView1_NodeClick(byval Node as MSComctlLib.Node)
    Dim i as Integer
    If lastnodeIndex <> 0 then
    TreeView1.Nodes(lastnodeIndex).BackColor = &H8000000D
    TreeView1.Nodes(lastnodeIndex).ForeColor = &H80000005
    End If
    If itemSelected then
    Node.BackColor = &H8000000D
    Node.ForeColor = &H80000005
    else
    With TreeView1
    for i = 1 to .Nodes.Count
    .Nodes(i).BackColor = &H80000005
    .Nodes(i).ForeColor = &H80000012
    next i
    End With
    End If
    lastnodeIndex = Node.Index
    End Sub




    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Nov 2000
    Location
    Israel
    Posts
    72

    Re: Multi Selection on TreeView

    Thank you very very much.


    Smile, Shmulik. (-;

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