Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid Speed
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Miscellaneous
Thread ID:
00066259
Message ID:
00066835
Views:
65
Paul,

Here's a test form I created tonight if creates a cursor 50 cols x 20 rows. Putting a random color in each field to create a real patchwork-quilt grid when it displays. It calls a form level method to set the DynBack just so we can watch the number of evals that get carried out.

PUBLIC ocform1

ocform1=CREATEOBJECT("cform1")
ocform1.Show
RETURN

DEFINE CLASS cform1 AS form

	Top = 0
	Left = 0
	Height = 289
	Width = 375
	DoCreate = .T.
	*-- Count of GenColor calls
	ncount = 0
	Name = "Cform1"

	ADD OBJECT grid1 AS grid WITH ;
		Height = 234, ;
		Left = 5, ;
		RecordSource = "dyntest", ;
		Top = 9, ;
		Width = 366, ;
		Name = "Grid1"

	ADD OBJECT text1 AS textbox WITH ;
		ControlSource = "thisform.nCount", ;
		Height = 23, ;
		Left = 15, ;
		Top = 256, ;
		Width = 100, ;
		Name = "Text1"


	PROCEDURE gencolor
		lparameter nColor

		this.nCount = this.nCount + 1
		this.Text1.Refresh()

		return nColor
	ENDPROC

	PROCEDURE Load
		create cursor dyntest ;
		     (a0 i, a1 i, a2 i, a3 i, a4 i, a5 i, a6 i, a7 i, a8 i, a9 i,;
		      b0 i, b1 i, b2 i, b3 i, b4 i, b5 i, b6 i, b7 i, b8 i, b9 i,;
		      c0 i, c1 i, c2 i, c3 i, c4 i, c5 i, c6 i, c7 i, c8 i, c9 i,;
		      d0 i, d1 i, d2 i, d3 i, d4 i, d5 i, d6 i, d7 i, d8 i, d9 i,;
		      e0 i, e1 i, e2 i, e3 i, e4 i, e5 i, e6 i, e7 i, e8 i, e9 i )

		append blank
		scatter to x

		for i = 1 to 20
		   if ( i > 1 )
		      append blank
		   endif
		   for j = 1 to 50
		      x[j] = rgb(int(rand()*255), int(rand()*255), int(rand()*255))
		   endfor
		   gather from x
		endfor

		goto top
	ENDPROC

	PROCEDURE Init
		for each loCol in this.Grid1.Columns
		   loCol.Sparse = .f.
		   loCol.DynamicBackColor = "thisform.GenColor( " + loCol.ControlSource + " )"
		endfor

		this.Grid1.Refresh()
	ENDPROC

ENDDEFINE


If you run it you'll see the number of times the Dyn* property is evaluated. The grid shows 11 rows of 5 cols, roughly 1/3 the number of cells as your grid. When the form first runs 440 times (8*visible cells) ! Clicking into the next row 1st col causes 113 (2*visible cells) more evals. So evidently VFP is indeed smart enough to not ro the dynamic stuff for cols/rows that are not visible. Clicking to scroll the grid one column causes another 110 evals. So clearly you want that code to be as absolutely efficient as possible.

> there are about 12 columns and about 11 rows showing at a time.>Hopefully this means that the grid is only dealing with 132 objects.
>

>Each plant is assigned a specific color, so each row for that plant is that color. This means possible 5 blue rows for plant x.

Then you might be able to add one shape for every row, it could turn the whole row blue... but the drag and drop will cause some headaches because the shape would see the drop event.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform