Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Where can I create the cursor before grid on form initia
Message
From
18/09/2006 10:13:51
James Blackburn
Qualty Design Systems, Inc.
Kuna, Idaho, United States
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01154646
Message ID:
01154680
Views:
28
This message has been marked as the solution to the initial question of the thread.
Have you tried bindcontrols? I have a couple of forms that worked for me. I set bindcontrols=.f. and then when I have my data environment setup I set it to .t..

>>O, I see.
>>Put it in Init event of the form and set Grid properties programaticly:
>
>The problem is much deeper than this. I already had the cursors created in the Form.Init(), I empty the RecordSource of the grid and I provide the new name of the cursors just as you mention.
>
>But the problem that I noticed is that even before the cursors are created, there is a view open to which the data-entry is made. The cursor even though it's own RecordSource is empty from design-time will take the automatic liberty to populate the columns as per this view.
>
>Then the code as you have outlined executes. Now the grid not only contains the 2 columns my cursors are supposed to have but also empty columns belonging to the view. So for eg. the view has 10 columns now after all this the grid has 2 columns from the cursor and 8 empty columns as the view is no longer the RecordSource.
>
>I know this sounds weird I can send a screen shot to explain what really happens.
>
>My original Form.Init()
>
LPARAMETERS tcCaption, tcSourceTable, tnMaxSelected
>
>
>LOCAL llRetVal, loSetAllX
>
>
>THIS.CAPTION = tcCaption
>
>
>llRetVal = DODEFAULT()
>
>
>IF llRetVal
>	THIS.cOldDeleted = SET("DELETED")
>
>	SET DELETED ON
>
>
>	THIS.cSourceTable = tcSourceTable
>
>
>	*** Populate Available Cursor/Grid
>	THIS.lstAvailable.RECORDSOURCE = ""
>
>	CloseUsed(THISFORM.icAvailableCursorName)
>	
>	SELECT * ;
>		FROM (tcSourceTable) ;
>		INTO CURSOR (THISFORM.icAvailableCursorName)
>		
>	MakeCursorRW()
>
>	THIS.lstAvailable.RECORDSOURCE = THISFORM.icAvailableCursorName
>	THIS.nAvailableCount           = RECCOUNT()
>
>
>	*** Populate Selected Cursor/Grid
>	THIS.lstSelected.RECORDSOURCE = ""
>
>	CloseUsed(THISFORM.icSelectedCursorName)
>
>	SELECT * ;
>		FROM (tcSourceTable) ;
>		INTO CURSOR (THISFORM.icSelectedCursorName)
>		
>	MakeCursorRW()
>
>	THIS.lstSelected.RECORDSOURCE = THISFORM.icSelectedCursorName
>	THIS.nSelectedCount           = 0
>
>	DELETE ALL
>
>
>	*** Make all the controls in the grid disabled so as it make them clickable
>	loSetAllX = CREATEOBJECT("SetAllX")
>
>	*loSetAllX.SetAllX(THIS.lstAvailable, "Enabled", .F.)
>	loSetAllX.SetAllX(THIS.lstAvailable, "DisabledForeColor", RGB(0,0,0))
>	loSetAllX.SetAllX(THIS.lstAvailable, "DisabledBackColor", RGB(192,192,192))
>
>	*loSetAllX.SetAllX(THIS.lstSelected , "Enabled", .F.)
>	loSetAllX.SetAllX(THIS.lstSelected, "DisabledForeColor", RGB(0,0,0))
>	loSetAllX.SetAllX(THIS.lstSelected, "DisabledBackColor", RGB(192,192,192))
>
>	loSetAllX = .NULL.
>
>
>	IF TYPE("tnMaxSelected") = "N" AND tnMaxSelected > 0
>		THIS.nMaxSelected = tnMaxSelected
>	ENDIF
>
>
>	IF FILE(THISFORM.icNoDropIcon)
>		THISFORM.lstAvailable.DRAGICON = FULLPATH(THISFORM.icNoDropIcon)
>		THISFORM.lstSelected.DRAGICON  = FULLPATH(THISFORM.icNoDropIcon)
>	ENDIF
>	
>	
>	DO CASE
>		CASE THIS.nMaxSelected = 1
>			THISFORM.cmdAddAll.SetVisible(.F.)
>			THISFORM.cmdRemoveAll.SetVisible(.F.)
>	
>		CASE THIS.nMaxSelected > 1
>			THISFORM.cmdAddAll.CAPTION = "Add Max " + ALLTRIM(STR(THIS.nMaxSelected))
>	ENDCASE
>ENDIF
>
>
>THISFORM.RemoveObject("cmdCancel")
>
>
>RETURN llRetVal
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform