Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Stefan Wuebbe
  Where is Stefan Wuebbe?
 Hamburg
 Germany
 Stefan Wuebbe
 To: Bong Bungalan
  Where is Bong Bungalan?
 gensan
 Philippines
 Bong Bungalan
 Tags
Subject: RE: Adding Header.Click() event at runtime
Thread ID: 268547 Message ID: 268626 # Views: 22 # Ratings: 0
Version: Visual FoxPro 9 Category: Classes and Objects
Date: Tuesday, July 13, 2010 4:17:35 PM         
   


Hi Bong,

> Hi stefan,
>
> By chance of trial and error and googling, i've come up with almost the same modifications exept of that [collate 'machine']. How important it is?
>

If you add an explicit Collate clause, you do not need to do an additional "Set Collate To ..." before (and after) your "Index On ..." line(s), so that each "Index On .." line would care for itself and would not depend on any (un)intentional environment settings.
(Collate=machine is the fastest one and also the default setting.)


> Also, I indexed all the Fields included (though there are fields that are not necessary to include) to avoid the error when I click on the header which is not indexed. Will this case affects the performance if by chance this view will hold hundreds of thousands records?
>

While each index tag indeed has its performance "costs", I'd say it might quite likely not make a noticeable performance difference in this case.

However, you can expand the previous code if you like by additionally doing something like checking whether a certain index tag is existing or not -> ATagInfo()

Or by explicitly storing (or not storing) the desired index tag name somewhere, for instance in the anyColumn.Tag property, so that your header.Click() code would "see" whether a specific column allows setting order or not.
Or by doing BindEvent() with certain columns only...



hth
-Stefan



LOCAL oForm
oForm = CREATEOBJECT('TestForm')
oForm.Show(1)
RETURN

DEFINE CLASS TestForm as Form
	AutoCenter = .T.
	AllowOutput = .F.

	PROCEDURE Load
		CREATE CURSOR temp (test C(10), test2 C(10))
		INDEX on test TAG test

		LOCAL i
		FOR i = 1 TO 26
			INSERT INTO temp VALUES (CHR(i+64),CHR(90-i))
		ENDFOR
		GO TOP
	ENDPROC

	ADD OBJECT Grid1 as Grid WITH ;
		RecordSource = 'temp', ;
		ColumnCount = 2, ;
		AllowCellSelection = .F.
	PROCEDURE Grid1.Init()
		This.Columns(1).Tag = 'test'

		Local loColumn
		For Each loColumn in This.Columns
			BINDEVENT(loColumn.Header1,'Click', Thisform, 'SetOrder')
		Next
	ENDPROC

	PROCEDURE SetOrder
		LOCAL laEventSource[1], lcTag, lcClause
		AEVENTS(laEventSource,0)
		lcTag = laEventSource[1].Parent.Tag
		IF !EMPTY(m.lcTag)
			lcClause = IIF(DESCENDING(),'A','De') + 'scending'
			SET ORDER TO (m.lcTag) &lcClause.
		ENDIF
		GO TOP IN temp
		Thisform.Grid1.Refresh()
	ENDPROC

ENDDEFINE


ENTIRE THREAD

Adding Header.Click() event at runtime Posted by Bong Bungalan @ 7/13/2010 8:15:49 AM
RE: Adding Header.Click() event at runtime Posted by Bhushan Sahni @ 7/13/2010 8:20:56 AM
RE: Adding Header.Click() event at runtime Posted by Bong Bungalan @ 7/13/2010 8:33:49 AM
RE: Adding Header.Click() event at runtime Posted by Bhushan Sahni @ 7/13/2010 8:35:09 AM
RE: Adding Header.Click() event at runtime Posted by Stefan Wuebbe @ 7/13/2010 8:37:29 AM
RE: Adding Header.Click() event at runtime Posted by Bong Bungalan @ 7/13/2010 9:12:34 AM
RE: Adding Header.Click() event at runtime Posted by Stefan Wuebbe @ 7/13/2010 10:00:19 AM
RE: Adding Header.Click() event at runtime Posted by Bong Bungalan @ 7/13/2010 2:18:31 PM
RE: Adding Header.Click() event at runtime Posted by Stefan Wuebbe @ 7/13/2010 3:29:19 PM
RE: Adding Header.Click() event at runtime Posted by Bong Bungalan @ 7/13/2010 3:52:15 PM
RE: Adding Header.Click() event at runtime Posted by Stefan Wuebbe @ 7/13/2010 4:17:35 PM
RE: Adding Header.Click() event at runtime Posted by Bong Bungalan @ 7/13/2010 4:31:10 PM
RE: Adding Header.Click() event at runtime Posted by tushar @ 7/13/2010 4:23:10 PM
RE: Adding Header.Click() event at runtime Posted by Bong Bungalan @ 7/13/2010 4:37:24 PM
RE: Adding Header.Click() event at runtime Posted by tushar @ 7/13/2010 4:43:17 PM
RE: Adding Header.Click() event at runtime Posted by tushar @ 7/13/2010 8:46:25 AM