Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Combo Boxes
Message
 
À
18/03/1997 11:16:22
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Titre:
Divers
Thread ID:
00024667
Message ID:
00025026
Vues:
35
>Hi Tim. My name is Marvin and I am new to VFP 3 and the Universal Thread, (since yesterday). The first message I saw on the thread was the very one I needed to see. It was you for help with ComboBoxes. I have to create an application that would benefit from the way you are using ComboBoxes, having one depend on another.

Marvin,

This can be done very easily when the ComboBoxes are not in a Grid. Here is some sample code. It comes in two files Test.prg and Country1a.qpr. Put them in the same directory and run Test.prg. I hope this helps.

* Call this file C:\Temp\Test.prg

LOCAL loTest

loTest = CREATEOBJECT("Test")
IF TYPE("loTest.Name") == "C" && If object was created...
loTest.Show(1) && Show modal form
ENDIF

RETURN


DEFINE CLASS test AS form
DoCreate = .T.
Caption = "Form"
Name = "test"

ADD OBJECT cbocontinent AS combobox WITH ;
RowSourceType = 3, ;
RowSource = "SELECT cContinent FROM Continent ORDER BY 1 INTO CURSOR Continent1a", ;
Height = 24, ;
Left = 116, ;
Style = 2, ;
Top = 44, ;
Width = 112, ;
Name = "cboContinent"

ADD OBJECT cbocountry AS combobox WITH ;
RowSourceType = 4, ;
RowSource = "Country1a", ;
Height = 24, ;
Left = 116, ;
Style = 2, ;
Top = 86, ;
Width = 112, ;
Name = "cboCountry"

PROCEDURE Load
CREATE CURSOR Country (cCountry c(20), cContinent C(20))
INSERT INTO Country VALUES ("USA", "North America")
INSERT INTO Country VALUES ("Canada", "North America")
INSERT INTO Country VALUES ("Spain", "Europe")
INSERT INTO Country VALUES ("France", "Europe")

CREATE CURSOR Continent (cContinent C(20))
INSERT INTO Continent VALUES ("North America")
INSERT INTO Continent VALUES ("Europe")

RETURN
ENDPROC

PROCEDURE cbocontinent.Valid
WITH This.Parent.cboCountry && Country ComboBox
.Requery() && Show Countries for Continent
.Refresh() && Refresh Country ComboBox
ENDWITH

RETURN
ENDPROC
ENDDEFINE

* Call this file C:\Temp\Country1a.qpr

LOCAL lcContinent

lcContinent = IIF(TYPE("_SCREEN.ActiveForm.cboContinent.Value") == "C", ;
_SCREEN.ActiveForm.cboContinent.Value, "*")

SELECT cCountry ;
FROM Country ;
WHERE cContinent = lcContinent ;
ORDER BY 1 ;
INTO CURSOR Country1a

RETURN
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform