CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 1999
    Location
    belgium
    Posts
    31

    Locking checkboxes in a Treeview control

    hi all,

    i'm searching for a solution to this simple problem for a while but didn't find it..(but i'm sure the solution is simple :-)

    i would like to prevent the user from modifying the checkbox status of a treeview..(like a read-only mode)
    i tried this:


    private Sub TreeView_NodeCheck(byval Node as MSComctlLib.Node)

    if Node.Checked = true then
    Node.Checked = false
    end if

    End Sub




    but no way...can someone give me a hint ?
    thanx


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

    Re: Locking checkboxes in a Treeview control


    'You can play with this
    private Sub TreeView1_MouseDown(Button as Integer, Shift as Integer, x as Single, y as Single)
    TreeView1.Enabled = false
    Call TreeView1_MouseUp(Button, Shift, x, y)
    End Sub

    private Sub TreeView1_MouseUp(Button as Integer, Shift as Integer, x as Single, y as Single)
    Dim n as Node
    TreeView1.Enabled = true
    for Each n In TreeView1.Nodes
    'This triggers the NodeCheck event
    n.Checked = false
    next
    End Sub





    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright,Bruno Paris
    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
    Aug 1999
    Location
    belgium
    Posts
    31

    Re: Locking checkboxes in a Treeview control

    This means that everytime that i click somewhere on the treeview window, the program will uncheck all the nodes ? (that is not exactly what i want but ok, what i want is just keep the status..)

    isn't it an 'expensive' solution ? isn't it the unique solution ?

    thanx
    Anis


    oilelele, oilala, faciela veder, faciela toccar..


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

    Re: Locking checkboxes in a Treeview control

    >>oilelee...
    You sure you are form Belgium?

    About keeping status, you may have an array where to store informations about checked-unchecked node, and in mouseup event restore these informations.
    Yes, it is expensive, but if you have less than 30 nodes you will not notice it. I have not found another solution.
    Have a nice day,
    Cesare

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris
    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.

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