Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
FAQ ID: 7967 Comment
Message
De
06/03/2009 10:52:55
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Titre:
FAQ ID: 7967 Comment
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Divers
Thread ID:
01386198
Message ID:
01386198
Vues:
325
Hi All,
Hi Mike Helland

Summary: In order to create a more flexible grid, some developers choose to build the grid's columns and controls at run-time. But since you can't add code to events and methods at run-time, you've got a bit of a dilemma.

I had just find a way that you could add an events at run-time to the grid.

I did not make full tests to see if you can create grid column in the class (vcx) instead of doing it in prg, but this please

- Create a Form, Add Grid
** Grid_Init
this.recordsource = 'MyTable'

Text To cClassCode noshow 
define class MyHeader as header
	name = 'MyHeader'
	proc Click
		* Create an Index and use it
		local lcFileName, lcField
		lcFileName = 'mhtest' + sys(3) + '.idx'
		lcField = this.caption
		index on &lcField to (lcFileName)
		thisform.refresh()
	EndProc
EndDefine 
EndText 
StrToFile(cClassCode,"c:\xx.prg")
Set Library To c:\xx.prg ADDITIVE 

local lnFields, laFields[1], lnI
		with this
			* For every field in the chosen table add a column
			lnFields = afields(laFields)
			.ColumnCount = 0
			for lnI = 1 to lnFields
				.AddColumn(lnI)
				with .Columns[lnI]
					* Remove the old header and add ours
					.RemoveObject('Header1')
					.AddObject('Header1', 'MyHeader')
					.Header1.Caption = laFields[lnI, 1]
					.ControlSource = 'MyTable.' + laFields[lnI, 1]
				endwith
			endfor
		EndWith
* oGridHeader = NewObject("MyHeader","c:\xx.prg")
* MessageBox(oGridHeader)
** In Form_Load
use ? alias MyTable
if not used()
	wait window 'No table was chosen'
	return .F.
endif
That is all your code, from your FAQ, but I only create the class header in the form instead of prg.

And you can do that in class (vcx)
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform