Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP6SP5 + TreeView: Stick to the record/node before update
Message
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Title:
VFP6SP5 + TreeView: Stick to the record/node before update
Miscellaneous
Thread ID:
00778295
Message ID:
00778295
Views:
52
Hi all

I have this treeview form etc. All is well till I save the record that I have just added or edited. The pointer shifts to the last expanded node.

I would like to stop this behaviour and would like to keep the node pointer to the node that was just saved. I have done a mix-match of treeview codes from various souces and added my codes as required to as follows. Not being the original author, this makes debugging tough for me. I am calling buildtree() the aftersave() of the form.

Q1. If anybody can help me move the node pointer back to the node I just saved please let me know.
Q2. Also is there a way to find out properties and methods of OCXs?


buildtree:
LPARAMETERS tlNo1stNode


* constants used in treeview NODES.ADD method
#DEFINE tvwFirst	0
#DEFINE tvwLast		1
#DEFINE tvwNext		2
#DEFINE tvwPrevious	3
#DEFINE tvwChild	4


LOCAL llCheckExpanded, laExpanded[1], lo, loNode, loNode1, lcVN, lcID, lcPID, lcText, lcOrder


THISFORM.LOCKSCREEN = .T.


* If there are any items already in the tree, save the expanded status
* of each one.
llCheckExpanded = THIS.oleTreeView.Nodes.COUNT > 0

IF llCheckExpanded
	THIS.GetExpanded(@laExpanded)
ENDIF


* while the Remove method removes a single node
* the Clear method removes all nodes from the treeview
THIS.oleTreeView.Nodes.CLEAR()


lo = THIS.oleTreeView



THIS.oDEManage.PUSH()

lcVN    = THIS.cViewName
lcID    = THIS.cID
lcPID   = THIS.cParentID
lcText  = THIS.cText
lcOrder = THIS.cOrder

SELECT "R" + STR(&lcID.) AS iID, &lcText. AS cName ;
	FROM (THIS.cDBCName + "!" + lcVN) ;
	WHERE !DELETED() AND EMPTY(&lcPID.) ;
	ORDER BY &lcOrder. ;
	INTO CURSOR tQuery

SELECT tQuery
LOCATE

SCAN
	loNode = THIS.AddOneNode(tQuery.iID, ALLTRIM(tQuery.cName))


	* Load the orders for this customer if necessary.
	THIS.AddChildren(tQuery.iID, loNode)
ENDSCAN

USE IN tQuery

THIS.oDEManage.POP()


* If there were any items already in the tree, set the expanded status
* of each one.
IF llCheckExpanded
	THIS.SetExpanded(@laExpanded)
ENDIF

THISFORM.LOCKSCREEN = .F.

WAIT CLEAR


IF !tlNo1stNode
	* sets the selected node to the first one in the collection
	lo.SELECTEDITEM = lo.Nodes(1)

	THIS.UpdateFromTreeView(lo.SELECTEDITEM)
ENDIF
setexpanded:
LPARAMETERS taExpanded

LOCAL lnI, lnNode

WITH THIS.oleTreeView
	FOR lnI = 1 TO .Nodes.COUNT
		lnNode = ASCAN(taExpanded, .Nodes[lnI].FULLPATH)

		IF lnNode > 0
			lnNode = ASUBSCRIPT(taExpanded, lnNode, 1)

			IF taExpanded[lnNode, 2]
				.Nodes[lnI].Expanded = .T.
			ENDIF
		ENDIF
	NEXT
ENDWITH
getexpanded:
LPARAMETERS taExpanded

LOCAL lnI

WITH THIS.oleTreeView
	DIMENSION taExpanded[.Nodes.Count, 2]

	FOR lnI = 1 TO .Nodes.COUNT
		taExpanded[lnI, 1] = .Nodes[lnI].FULLPATH
		taExpanded[lnI, 2] = .Nodes[lnI].Expanded
	NEXT
ENDWITH
Regards
Bhavbhuti
___________________________________________
Softwares for Indian Businesses at:
http://venussoftop.tripod.com
___________________________________________
venussoftop@gmail.com
___________________________________________
Next
Reply
Map
View

Click here to load this message in the networking platform