Problems with preventing the user of setting a checkbox of a treeview

J

Jurry

I want to prevent that users select certain checkboxes of a treeview.
tried doing that by placing a routine in the NodeCheck event of th
treeview. During debuging I see the checkbox being set back to my ow
value, but after the whole event the checkbox has the users value! S
in short the following code does not work, why not?

Private Sub treeSpotsOverview_NodeCheck(ByVal Node As MSComctlLib.Node

tree.Nodes(Node.index).Checked = True
End Sub

Thanks, Jurry.
PS: I'm using VBA
 
J

Jurry

After searching on the net I found the following workaround for this BU
in VB: you have the use the event MouseUp. This event takes alway
place after the clicking of a node by the user (and therefore AFTER th
NodeCheck event). In combination with a global var the result is:

In a standard module:

Code
-------------------
Public gnodNodeWithCheckboxToBeProcessed As MSComctlLib.Nod
-------------------

In the treeview dialog module:

Code
-------------------
Private Sub treeSpotsOverview_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As stdole.OLE_XPOS_PIXELS, ByVal y As stdole.OLE_YPOS_PIXELS)
' used to work around the bug in VB to alter the checkbox state during the
' nodecheck event
If Not gnodNodeWithCheckboxToBeProcessed Is Nothing Then
gupvlPlateValues.HandleTreeCheckboxChange gnodNodeWithCheckboxToBeProcessed
Set gnodNodeWithCheckboxToBeProcessed = Nothing
End If
End Sub

Private Sub treeSpotsOverview_NodeCheck(ByVal Node As MSComctlLib.Node)
' Actual action in the mouseup event due to bug of VB
Set gnodNodeWithCheckboxToBeProcessed = treeSpotsOverview.Nodes(Node.Index)
End Su
 
Top