Click to See Complete Forum and Search --> : Locking checkboxes in a Treeview control
Anis
August 1st, 2001, 07:47 AM
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
Cimperiali
August 1st, 2001, 09:50 AM
'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
Anis
August 3rd, 2001, 01:46 AM
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..
Cimperiali
August 3rd, 2001, 02:08 AM
>>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
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.