See my comments below
>I am having one form which has a treeview named (oletree)
>
>In the nodeclick event I have written the following code.
>This code works fine. But when I click on a node which has childrens then
>the children's are getting marked. f I click the node again to unselect it, I get the following error.
>
>Fatal Error : Exception Code = C0000005 called from oletree.nodeclick line 17
>
>or the following error message
>
>Prepery not found
>
>2. I also want to know can I write the same code on nodecheck event.
>Because the selected property is not available in nodecheck event.
>If this is not possible can I make the nodecheck disable so that whenever user
>clicks on node programatticallY I will mark or unmark it.You don't have to figure ot what the current node is because both NodeClick and NodeCheck Events get reference to the current node as a parameter
Lparameters Node
>
>3. Basically I want the user to select multiple records so that when he clicks on abutton (on the form) then the selected records will be populates in another tree and will get deleted from the "oletree". For this I am using the selected records in a dbf file called "Nodebuild"
To make the code simplier add a field named 'NodeChecked' to your table Nodebuild and change it accordingly instead of deleting/recalling records. AT the end process only records with 'NodeChecked' = .T.
>4. After clicking on node (Which has chield)
>IF I click on close button which has the following code
>
>close all
>*thisform.unload
>thisform.release
>
>Nothing happens. Form is not getting closed and I have to close foxpro application by selecting File->Exit.
You don't have to call Unload of the form because it's called automatically when form closes. Thisfor.Release shoud be enough. It sounds like there're dangling object reference to the objects on your form. For detailed explanation see
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfoxtk99/html/FT99J8.asp?frame=trueThe code below should do what you want but I didn't test it. Look at it as a sample. It assumes that you would create two custom method on the form UpdateChecked and UpdateNodebuild.
Lparameters Node
Thisform.UpdateChecked(node)
EndProc
Lparameters Node
Thisform.UpdateChecked(node)
EndProc
Procedure UpdateChecked
Lparameters toNode
Local loRef
toNode.checked = Not toNode.checked
If toNode.children > 0
loRef = toNode.Child
Do While .T.
If Isnull( loref)
Exit
Endif
loRef.checked = Not loref.checked
Thisform.UpdateNodebuild(loRef)
loRef = loref.Next
Enddo
Else
Thisform.UpdateNodebuild(toNode)
Endif
EndProc
Procedure UpdateNodebuild
Lparameters toRef
Locate rKey, rTxt, rChecked
rKey = toRef.Key
rTxt = toRef.Text
rChecked = toRef.checked
Select nodebuild
If Not Seek( rKey )
Append Blank
Replace nodekey With rKey, nodetext With rTxt
Endif
Replace nodechecked With rChecked
EndProc
--sb--