Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid
Message
De
21/07/2008 14:04:16
 
 
À
21/07/2008 00:00:24
Muthu Vel
Sty Company
Inde
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Re: Grid
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01332698
Message ID:
01332894
Vues:
15
>I have create emp entry.scx. In that I have placed five text boxes, one Grid control, one command button.
>
>I have enter the data in the text boxes and click command button the entered record will dispaly in the Grid.
>
>How to write the code?
Here is some example code: The record source for the grid in this example is the "z1" cursor with three fields. Type the information into the provided fiedls and click the button to add a record into the "Z1" cursor.


CREATE CURSOR Z1 (Field1 C(10),FIeLD2 C(10),FIELD3 C(10))
loForm=CREATEOBJECT("form")
loform.show
loform.caption="Example"
loform.height=450
loform.visible=.t.
loForm.Addobject('txtBox1','TextBox')
loForm.Addobject('txtBox2','TextBox')
loForm.Addobject('txtBox3','TextBox')
loForm.txtBox1.Left=50
loForm.txtBox1.Width=100
loForm.txtBox1.top=10
loForm.txtBox2.Left=160
loForm.txtBox2.Width=100
loForm.txtBox2.top=10
loForm.txtBox3.Left=270
loForm.txtBox3.Width=100
loForm.txtBox3.top=10
loForm.txtBox1.Visible=.t.
loForm.txtBox2.Visible=.t.
loForm.txtBox3.Visible=.t.

loForm.Addobject('grdZ1','Grid')
loForm.grdZ1.RecordSourceType=1
loForm.grdZ1.RecordSource='Z1'
loForm.grdZ1.Left=50
loForm.grdZ1.top=50

loForm.grdZ1.Visible=.t.
loForm.Addobject('cmdCmndBtn','cmdMyCmndBtn')

loForm.cmdCmndBtn.Visible=.t.
loForm.Addobject('cmdExit','cmdMyExit')
loForm.cmdExit.Visible=.t.

READ events
DEFINE CLASS cmdMyExit AS CommandButton && Create Command button
Caption = 'Exit' && Caption on the Command button
Cancel = .T. && Default Cancel Command button (Esc)
Left = 170 && Command button column
Top = 300 && Command button row
Height = 25 && Command button height

PROCEDURE Click
CLEAR EVENTS && Stop event processing, close Form
ENDDEFINE
DEFINE CLASS cmdMyCmndBtn AS COMMANDBUTTON && Create Command button
Caption = 'Add new record' && Caption on the Command button
Left = 50 && Command button column
Top = 300 && Command button row
Height = 25 && Command button height

PROCEDURE Click
SELECT Z1
APPEND BLANK
replace Field1 WITH This.parent.txtBox1.value,;
Field2 WITH This.parent.txtBox2.value,;
Field3 WITH This.parent.txtBox3.value
This.parent.grdZ1.Refresh()
This.parent.txtBox1.value=SPACE(10)
This.parent.txtBox2.value=SPACE(10)
This.parent.txtBox3.value=SPACE(10)

ENDDEFINE

<\PRE>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform