Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
FAQ ID: 7967 Comment
Message
 
À
06/03/2009 10:52:55
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Divers
Thread ID:
01386198
Message ID:
01386225
Vues:
116
another option is to have methods on your base grid class and use bindevents
for example to fire code in right click, double click, header click
For ix = 1 ToThis.ColumnCount

	lcIx = Alltrim(Str(ix))

	Bindevent(This.Column&lcIx..header1,'click',This,'m_headerClick',1)
	Bindevent(This.Column&lcIx..text1,'dblclick',This,'m_DoubleClick',1)
	Bindevent(This.Column&lcIx..text1,'rightclick',This,'m_rightClick',1)
Endfor
and then to identify where the action took place use aevents
Aevents( laWhichEvent, 0 )

lnColumnNumber = laWhichEvent[1,1].Parent.ColumnOrder
lcColumnNumberCharacter = Alltrim(Str(lnColumnNumber))
>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)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform