Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid Locked
Message
From
14/05/1998 00:21:31
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
13/05/1998 17:33:34
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00099245
Message ID:
00099306
Views:
29
>I have posted several questions about problems I have had using a grid - specifically trying to make 2 separate grids display the same records from different tables when the selected record in the first grid changes. I have had trouble finding out in which row of Grid 2 the selected record is displayed. Several of you have posted answers that have been very helpful.
>
>I have been testing with a small form with a grid and have discovered this reaction, which I can't explain. The ActiveRow and ActiveColumn and RelativeRow and RelativeColumn properties are available in the test UNTIL read events is executed. After that point, those 4 properties always display 0. And I think that may be why I have not been able to figure out the current active row in Grid 2.
>
>Does this scenario make sense?
>Thanks
>Mark
Mark,
They would display 0 unless the grid has focus. Instead subclass a grid to hold recno() or setfocus to grid2, use them and reset focus back to grid1. Another way is to partition the grid. You could use this class maybe :
**************************************************
*-- Class:        highlighted (c:\temp\test.vcx)
*-- ParentClass:  grid
*-- BaseClass:    grid
*-- Current row highlighted grid.
*
DEFINE CLASS highlighted AS grid

	Height = 200
	Width = 320
	ccurrecbackcolor = (RGB(0,0,255))
	ccurrecforecolor = (RGB(255,255,0))
	PROTECTED lingrid
	lingrid = .T.
	ncurrec = .F.
	Name = "highlighted"

	PROCEDURE When
		this.lInGrid = .T.
	ENDPROC

	PROCEDURE Valid
		this.lInGrid = .F.
	ENDPROC

	PROCEDURE Init
		WITH this
			IF !empty(.RecordSource)
				.nCurRec = recno(this.RecordSource)
				.SetAll("DynamicBackColor", "IIF(RecNo(This.RecordSource) = This.nCurRec," + ;
					str(this.cCurRecBackColor)+","+str(this.BackColor)+")", "Column")
				.SetAll("DynamicForeColor", "IIF(RecNo(This.RecordSource) = This.nCurRec," + ;
					str(this.cCurRecForeColor)+","+str(this.ForeColor)+")", "Column")
			ENDIF
		ENDWITH
	ENDPROC

	PROCEDURE BeforeRowColChange
		LPARAMETERS nColIndex
		thisform.LockScreen = this.lInGrid
	ENDPROC

	PROCEDURE AfterRowColChange
		LPARAMETERS nColIndex
		this.nCurRec = recno(This.RecordSource)
		thisform.LockScreen = .F.
		IF !this.lInGrid
			this.refresh()
		ENDIF
	ENDPROC

	*-- Refresh when recpointer moves. For calling outside of grid.
	PROCEDURE recchange
		This.nCurRec = recno()
		This.refresh
	ENDPROC


ENDDEFINE
*
*-- EndDefine: highlighted
**************************************************
From grid1 you could call grid2.recchange().
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform