Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid doesn't display data
Message
From
17/06/2019 18:00:31
 
 
To
17/06/2019 17:35:58
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01669110
Message ID:
01669134
Views:
58
>>>>>Perhaps I've been .Net'ing too much, but I can't seem to get a Grid to display the data that it should be showing.
>>>>>
>>>>>Data exists in a cursor 'PersonClass'
>>>>>Grid sits on the 2nd page of a pageframe
>>>>>
>>>>>In the GetInfo method of the form I have:
>>>>> [...]
>>>>>So, what have I forgotten?
>>>>
>>>>When is GetInfo() called?
>>>
>>>Right after looking up the ID entered into the form, make sure it exists in the tables and then get the rest of the information for this person. So, basically, in the Valid method of the ID entry field
>>
>>The ID entry field is in the same page? Or somewhere else in the form?
>
>ID entry field is on the first page of a 2 page pageframe. Grid is on 2nd page along with some education information fields, which are getting populated. The only thing that isn't is the grid.

Dorris, I would double check if GetInfo is being called.

There is nothing complicated in getting things working in the way you designed.
CREATE CURSOR SomeData (Id Int Autoinc, Name Varchar(12), Sex Char(1))

INSERT INTO SomeData (Name, Sex) VALUES ('Jerry', 'M')
INSERT INTO SomeData (Name, Sex) VALUES ('George', 'M')
INSERT INTO SomeData (Name, Sex) VALUES ('Elaine', 'F')
INSERT INTO SomeData (Name, Sex) VALUES ('Cosmo', 'M')

LOCAL Test AS TwoPagedForm

m.Test = CREATEOBJECT("TwoPagedForm")
m.Test.Show(1)

DEFINE CLASS TwoPagedForm AS Form

	ADD OBJECT pgf AS PageFrame WITH PageCount = 2

	FUNCTION Init

		WITH This.pgf.Pages(1) AS Page

			.AddObject("txt", "Textbox")
			.txt.Visible = .T.

		ENDWITH

		WITH This.pgf.Pages(2) AS Page

			.AddObject("grd", "Grid")
			.grd.Visible = .T.

		ENDWITH

		BINDEVENT(This.pgf.Pages(1).txt, "LostFocus", This, "GetInfo", 1)

	ENDFUNC

	FUNCTION Destroy
		UNBINDEVENTS(This)
	ENDFUNC

	FUNCTION GetInfo

		SELECT * FROM SomeData WHERE Sex == UPPER(ALLTRIM(This.pgf.Pages(1).txt.Value)) INTO CURSOR SomeFilteredData
		GO TOP IN SomeFilteredData

		WITH Thisform.pgf.Pages(2) AS Page

			WITH .grd AS Grid

				.RecordSource = "SomeFilteredData"
				.RecordSourceType = 1
				.ColumnCount = 2

				WITH .Columns(1) AS Column
					.Alignment = 0
					.Header1.Caption = "Name"
					.ControlSource = "SomeFilteredData.Name"
					.Width = 100
				ENDWITH

				WITH .Columns(2) AS Column
					.Alignment = 1
					.Header1.Caption = "Id"
					.ControlSource = "SomeFilteredData.Id"
					.Width = 100
				ENDWITH

			ENDWITH

		ENDWITH

	ENDFUNC

ENDDEFINE
----------------------------------
António Tavares Lopes
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform