Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Pete Sass
  Where is Pete Sass?
 Marathon, Ontario
 Pete Sass
 To: Ken Blum
  Where is Ken Blum?
 Illinois - United States
 Ken Blum
Subject: RE: Data manipulation using Grid
Thread ID: 22876 Message ID: 22905 # Views: 7 # Ratings: 0
Version: Visual FoxPro 6 Category: Classes and Objects
Date: Tuesday, April 29, 2003 8:43:26 PM         

> > Hallo,
> > I want to make some modules on my program can manipulate (adding,editing,deleting) some data/records of database files from/using Grid Component.
> > What should I do?
> >
> > Cheers,
> > Ellen
> Create a new form. RightClick on the form and select Data Environment. Add your table to the data environment. Drag and drop the entire table from the Data Environment onto the form. It will create the default grid for you.
> If you drag & drop a field from the table to the form, it will create a textbox for that field.

Grids are lots of fun....lol

There are two ways of handling what you are asking.

First way
Have a seperate set of command buttons on your form to add data into the grid.
This is not hard to do. Set your grid as a default as readonly=.t.
You click on and Add, or Edit button set the grid for readonly=.f.
With add - Append blank and issue Thisform.Refresh
and set the focus to the gird object you wish the user to start inputing at.

With Edit, same idea. Set the grid to readonly=.f. and set the focus.

Since the user has the ability to move up and down in the grid and may
change more than one record, ensure the cursor is set for buffering = 5
and with the tableupdate command make sure you use the following:
=TABLEUPDATE(.T.) to force all changed in the table to the backend.

You can use the valid event to ensure data is entered as it should be,
or with a Save command button test for input and set the focus back
to the grid object that is lacking, or in error.

Second Way
Use the dbf() to logical decide what table you are accessing. So if
clicking in the grid the dbf() will return that table name. Paln your
logic based upon this. If a parent table is being used, clicking on
that object will return via the dbf() the table being changed and
plan your logic based upon this return.

I personally like the seperate command buttons; one set for the parent
and one for the grid to remove any user issues.

Pete from the Great White North. (Only in Canada, ay.) Over and Out ...


Data manipulation using Grid Posted by Ellen Kawengian @ 4/29/2003 9:54:26 AM
RE: Data manipulation using Grid Posted by Ken Blum @ 4/29/2003 3:34:15 PM
RE: Data manipulation using Grid Posted by Pete Sass @ 4/29/2003 8:43:26 PM