PUBLIC oform1
oform1 = NEWOBJECT("form1")
oform1.Show
RETURN
DEFINE CLASS form1 AS form
BorderStyle = 2
Height = 263
Width = 529
DoCreate = .T.
AutoCenter = .T.
Caption = "Form1"
Name = "Form1"
ADD OBJECT list1 AS listbox WITH ;
Height = 246, ;
Left = 6, ;
Top = 8, ;
Width = 234, ;
Name = "List1"
ADD OBJECT command1 AS commandbutton WITH ;
Top = 222, ;
Left = 302, ;
Height = 32, ;
Width = 169, ;
Caption = "Release", ;
Name = "Command1"
ADD OBJECT edit1 AS editbox WITH ;
Height = 208, ;
Left = 246, ;
ReadOnly = .T., ;
ScrollBars = 0, ;
Top = 8, ;
Width = 276, ;
Name = "Edit1"
PROCEDURE RefreshEditBox
Thisform.Edit1.Value = Chr(215) + Chr(215) + Chr(215) + " List values " + Chr(215) + Chr(215) + Chr(215) + Chr(13) ;
+ "List Item: " + Alltrim(Thisform.List1.List(Thisform.List1.ListItemId)) + Chr(13) ;
+ "List Item ID: " + Alltrim(Thisform.List1.Value) + Chr(13) + Chr(13) ;
+ Chr(215) + Chr(215) + Chr(215) + " Table fields values " + Chr(215) + Chr(215) + Chr(215) + Chr(13) ;
+ "crName: First Name = " + Alltrim(crName.first_name) + Chr(13) ;
+ "crName: Last Name = " + Alltrim(crName.last_name) + Chr(13) ;
+ "crName: ID = " + Alltrim(Str(crName.Id)) + Chr(13) ;
+ "crName: RecNo = " + Alltrim(Str(Recno())) + Chr(13) + Chr(13) ;
+ "crCountry: ID = " + Alltrim(Str(crCountry.Id)) + Chr(13) ;
+ "crCountry: Country = " + Alltrim(crCountry.country) + Chr(13) ;
+ "crCountry: Continent (for IIF) = " + Alltrim(Str(crCountry.continent))
Thisform.Edit1.Refresh
ENDPROC
PROCEDURE Init
Close Databases All
Create Cursor crName (Id N(5), first_name C(20), last_name C(30))
Insert Into crName (Id, first_name, last_name) Values (1, "John", "Doe")
Insert Into crName (Id, first_name, last_name) Values (2, "Crazy", "Horse")
Insert Into crName (Id, first_name, last_name) Values (3, "Rita", "Dotson")
Insert Into crName (Id, first_name, last_name) Values (4, "Tin", "Man")
Insert Into crName (Id, first_name, last_name) Values (5, "Estelle", "Mcleod")
Insert Into crName (Id, first_name, last_name) Values (6, "Maria", "Popescu")
Insert Into crName (Id, first_name, last_name) Values (7, "Rodriguez", "Morales")
Index On Id Tag Id
Index On Alltrim(first_name) + Alltrim(last_name) Tag Name Ascending Additive
Create Cursor crCountry (Id N(5), country C(20), continent N(5))
Insert Into crCountry (Id, country, continent) Values (1, "Great Britain", 1)
Insert Into crCountry (Id, country, continent) Values (2, "U.S.A.", 2)
Insert Into crCountry (Id, country, continent) Values (3, "Germany", 1)
Insert Into crCountry (Id, country, continent) Values (4, "Land of Oz", 3)
Insert Into crCountry (Id, country, continent) Values (5, "France", 1)
Insert Into crCountry (Id, country, continent) Values (6, "Romania", 1)
Insert Into crCountry (Id, country, continent) Values (7, "Spain", 1)
Index On Id Tag Id
Select crName
Set Relation To Id Into crCountry
Locate
LcRowSource = "Alltrim(Alltrim(crName.first_name) + ' ' + Alltrim(crName.last_name)) + ";
+ "' -> ' + Alltrim(crCountry.country) + ': ' + ";
+ "IIF(crCountry.continent = 1, 'Europe', IIF(crCountry.continent = 2, 'America', 'Magical Land')) ";
+ ", id"
With Thisform
.List1.ColumnCount = 1
.List1.BoundColumn = 2
.List1.RowSourceType = 6
.List1.RowSource = LcRowSource
.List1.SelectedID(1) = .T.
.RefreshEditBox()
Endwith
ENDPROC
PROCEDURE list1.InteractiveChange
Thisform.RefreshEditBox()
ENDPROC
PROCEDURE command1.Click
ThisForm.Release
ENDPROC
ENDDEFINE