Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. articles. downloads. faq. members. files. rss.
 From: António Lopes
  Where is António Lopes?
 Coimbra
 Portugal
 António Lopes
 To: Ilya Rabyy
  Where is Ilya Rabyy?
 Fountain Valley
 California - United States
 Ilya Rabyy
Subject: RE: Catch Grid.RecSource change - HOWTO?
Thread ID: 465224 Message ID: 465233 # Views: 55 # Ratings: 5
Version: Visual FoxPro 9 SP2 Category: Grids
Date: Tuesday, April 16, 2019 6:25:55 PM         
   



> >
> >
> > BINDEVENT to the recordsource?
> > Not tested though :-)
> >
> >
> > -----------------
> > Borislav Borissov
> >
> > Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
> > The only thing normal about database guys is their tables.
>
> BINDEVENT() supposed to have an event to bind to, which is exactly my question: what event is fired when an empty grid gets populated?
>
> BTW, I tried to use GRID.When event, but it requires grdMyGrid.SetFocus in the container's program and would not work without it.
>
> Regards,
>
> Ilya

Ilya,

In VFP, you can BINDEVENTS() to events but also to methods and properties (in case of a property, it is actually a binding to its _assign event). That's what Boris suggested you.

I don't know exactly what you are trying to do, but here it is a demo to complete Boris suggestion:

CREATE CURSOR C1 (Id Int, C1_Data Varchar(10))

INSERT INTO C1 VALUES (1, "Hello")
INSERT INTO C1 VALUES (2, "World")

GO TOP

CREATE CURSOR C2 (Id Int, C2_Data Varchar(50))

INSERT INTO C2 VALUES (1, "Venus")
INSERT INTO C2 VALUES (2, "Mercury")
INSERT INTO C2 VALUES (3, "Earth")

GO TOP

LOCAL test AS onGridPopulate

m.test = CREATEOBJECT("onGridPopulate")
m.test.Show(1)

DEFINE CLASS onGridPopulate AS Form

	ADD OBJECT C1 AS CommandButton WITH Top = 10, Caption = "C1"
	ADD OBJECT C2 AS CommandButton WITH Top = 30, Caption = "C2"
	ADD OBJECT grd AS Grid WITH Top = 50, RecordSource = "C1"

	PROCEDURE Init
		BINDEVENT(This.grd, "RecordSource", This.grd, "Alert")
	ENDPROC

	PROCEDURE Destroy
		UNBINDEVENTS(This.grd)
	ENDPROC

	PROCEDURE grd.Alert
		MESSAGEBOX("User selected a new cursor")
	ENDPROC

	PROCEDURE C1.Click
		Thisform.grd.RecordSource = "C1"
	ENDPROC

	PROCEDURE C2.Click
		Thisform.grd.RecordSource = "C2"
	ENDPROC

ENDDEFINE


ENTIRE THREAD

Catch Grid.RecSource change - HOWTO? Posted by Ilya Rabyy @ 4/16/2019 5:00:52 PM
RE: Catch Grid.RecSource change - HOWTO? Posted by Jun Tangunan @ 4/16/2019 5:07:35 PM
RE: Catch Grid.RecSource change - HOWTO? Posted by Ilya Rabyy @ 4/16/2019 5:36:53 PM
RE: Catch Grid.RecSource change - HOWTO? Posted by Jun Tangunan @ 4/16/2019 5:59:21 PM
RE: Catch Grid.RecSource change - HOWTO? Posted by Borislav Borissov @ 4/16/2019 5:08:44 PM
RE: Catch Grid.RecSource change - HOWTO? Posted by Ilya Rabyy @ 4/16/2019 5:30:32 PM
RE: Catch Grid.RecSource change - HOWTO? Posted by António Lopes @ 4/16/2019 6:25:55 PM
RE: Catch Grid.RecSource change - HOWTO? Posted by Ilya Rabyy @ 4/16/2019 9:42:30 PM
RE: Catch Grid.RecSource change - HOWTO? Posted by António Lopes @ 4/16/2019 10:55:50 PM
RE: Catch Grid.RecSource change - HOWTO? Posted by Ilya Rabyy @ 4/17/2019 3:57:49 PM
RE: Catch Grid.RecSource change - HOWTO? Posted by Tamar Granor @ 4/17/2019 10:31:04 PM
RE: Catch Grid.RecSource change - HOWTO? Posted by Ilya Rabyy @ 4/18/2019 4:59:50 PM
RE: Catch Grid.RecSource change - HOWTO? Posted by Mustapha Bihmouten @ 4/16/2019 5:14:52 PM
RE: Catch Grid.RecSource change - HOWTO? Posted by Ilya Rabyy @ 4/19/2019 6:45:28 PM