Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid - AfterRowColChange
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
00966222
Message ID:
00966464
Vues:
7
Hi Sergey,
Here is a repro:
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN

DEFINE CLASS form1 AS form

	DataSession = 2
	Height = 225
	Width = 301
	DoCreate = .T.
	AutoCenter = .T.
	Caption = "Form1"
	Name = "Form1"

	ADD OBJECT command2 AS commandbutton WITH ;
		Top = 193, ;
		Left = 18, ;
		Height = 27, ;
		Width = 46, ;
		Caption = "<", ;
		Name = "Command2"

	ADD OBJECT command3 AS commandbutton WITH ;
		Top = 193, ;
		Left = 75, ;
		Height = 27, ;
		Width = 46, ;
		Caption = ">", ;
		Name = "Command3"

	ADD OBJECT command5 AS commandbutton WITH ;
		Top = 193, ;
		Left = 225, ;
		Height = 27, ;
		Width = 46, ;
		Cancel = .T., ;
		Caption = "Exit", ;
		Name = "Command5"

	ADD OBJECT grdz AS grid WITH ;
		ColumnCount = 3, ;
		DeleteMark = .F., ;
		Height = 111, ;
		Left = 9, ;
		Panel = 1, ;
		RecordSource = "z", ;
		RecordSourceType = 1, ;
		ScrollBars = 2, ;
		Top = 6, ;
		Width = 285, ;
		AllowCellSelection = .F., ;
		Name = "grdZ", ;
		Column1.ControlSource = "z.f1", ;
		Column1.Width = 84, ;
		Column1.Name = "Column1", ;
		Column2.ControlSource = "z.f2", ;
		Column2.Width = 84, ;
		Column2.Name = "Column2", ;
		Column3.ControlSource = "z.f3", ;
		Column3.Width = 84, ;
		Column3.Name = "Column3"

	ADD OBJECT txtf1 AS textbox WITH ;
		Comment = "", ;
		ControlSource = "z.f1", ;
		Height = 23, ;
		Left = 18, ;
		TabIndex = 8, ;
		Top = 139, ;
		Width = 81, ;
		Name = "txtF1"

	ADD OBJECT txtf2 AS textbox WITH ;
		Comment = "", ;
		ControlSource = "z.f2", ;
		Height = 23, ;
		Left = 105, ;
		TabIndex = 10, ;
		Top = 139, ;
		Width = 81, ;
		Name = "txtF2"

	ADD OBJECT txtf3 AS textbox WITH ;
		Comment = "", ;
		ControlSource = "z.f3", ;
		Height = 23, ;
		Left = 192, ;
		TabIndex = 12, ;
		Top = 139, ;
		Width = 81, ;
		Name = "txtF3"

	ADD OBJECT txtdatetime AS textbox WITH ;
		Height = 23, ;
		Left = 18, ;
		TabIndex = 12, ;
		Top = 167, ;
		Width = 255, ;
		Name = "txtDatetime"

	ADD OBJECT check1 AS checkbox WITH ;
		Top = 119, ;
		Left = 20, ;
		Height = 17, ;
		Width = 120, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "AllowCellSelection", ;
		ControlSource = "thisform.grdz.allowcellselection", ;
		Name = "Check1"

	PROCEDURE Load
		local lnCnt
		create cursor z(f1 i, f2 i, f3 i)
		for lnCnt=1 to 5
			insert into z values (lnCnt, lnCnt+1, lnCnt+2)
		endfor
		go top
	ENDPROC

	PROCEDURE command2.Click
		if recno()>1
			skip -1
		endif
		*thisform.Refresh					&& this does NOT fire AfterRowColChange regardless of allowcellselection

		thisform.grdZ.SetFocus				&& this does NOT fire AfterRowColChange for allowcellselection .F.
											&& I know why (the cell cannot get focus)
											&& But the AfterRowColChange should fire when the row changes


		*thisform.grdZ.afterrowcolchange	&& this works for allowcellselection .F., is it the right thing to do?
	ENDPROC

	PROCEDURE command3.Click
		if recno()<5
			skip 1
		endif
		*thisform.Refresh					&& this does NOT fire AfterRowColChange regardless of allowcellselection

		thisform.grdZ.SetFocus				&& this does NOT fire AfterRowColChange for allowcellselection .F.
											&& I know why (the cell cannot get focus)
											&& But the AfterRowColChange should fire when the row changes


		*thisform.grdZ.afterrowcolchange	&& this works for allowcellselection .F., is it the right thing to do?
	ENDPROC

	PROCEDURE command5.Click
		thisform.Release
	ENDPROC

	PROCEDURE grdz.AfterRowColChange
		LPARAMETERS nColIndex

		thisform.txtDatetime.Value = transform(f1) + ' - ' + transform(seconds())
		thisform.Refresh
	ENDPROC

ENDDEFINE
>>A couple of grid questions:
>>1. The AfterRowColChange event triggers when you select a new cell using the mouse or the keyboard.
>>Q: Shouldn't the event trigger when the record pointer in the source table moves?
>>I think it should, because you can see the record marker and row highlight move, but it does not.
>>To get around this we put code in our classes that loops through the objects in a form when we move to another record, and if the object is a grid does a loControl.setfocus(). This however does not work when AllowCellelection is set to .F., because setfocus fails.

>
>Grid.setfocus() with AllowCellelection=.F. works fine for me. Can you post a simple code that repro this problem?
>
>>2. The help says that nColIndex (the AfterRowColChange para) "returns the index of the newly selected row or column", but it seems it always returns the column index.
>>Q: What would be the row index?
>
>The help is incorrect. It's always column 3 which is the same as ActiveColumn
>property.
>For the current row see ActiveRow property of the grid.
Doru
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform