×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Can you edit grid?

Can you edit grid?

Can you edit grid?

(OP)
I have a grid that displays record, can you delete a row or edit data from the grid? May i ask how? thanks...

RE: Can you edit grid?

Hi Mandy,

The short answer is Yes.

If you want to delete or edit a row from within your program, what you must do is to delete or edit the corresponding record in the underlying cursor or table. Remember, the grid is just a view of your table. Whatever changes you make in the table will be reflected in the grid. (You would usually need to either set focus on the grid or refresh it in order for the change to become visible.)

If you want to allow your user to delete or edit the grid interactively, that's posssible as well. In fact, a grid is editable by default. You don't need to take any special action to let the user click on a cell and edit it. To delete a record, they click on the narrow column at the extremem left edge of the grid.

Just to add: if you want to prevent the user from editing the grid, you should set its ReadOnly property to .T. You can also do that for individual columns in the grid. If you want to allow editing but prevent deletion, set the grid's DeleteMark property to .F.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Can you edit grid?

Hi Mandy,

In addition to Mike's post: you'll have to make sure that the grid's RECORDSOURCE is a Table. If it's a view or a cursor, things become more complicated and you'll have to "transfer" the changes to the underlying table(s)

hth

MarK

RE: Can you edit grid?

Mark, you're right about it being a cursor. I hadn't thought of that. But I think a view is different. Provided the settings are right, a grid can update a view which can in turn update the underlying table.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Can you edit grid?

Hi Mike

Quote:


Provided the settings are right, a grid can update a view which can in turn update the underlying table.

You're right. But

Quote:


Views are, by default, buffered with optimistic row buffering. You can change this to table buffering; for more information on buffering, see Chapter 17, Programming for Shared Access.

from VisualFoxPro 6 - Programmers Guide by Microsoft

Hence you have to TABLEUPDATE() them - perhaps in AFTERROWCOLCHANGE() or in LOSTFOCUS() of the grid - and only then the changes will be send to the underlying table(s) - depending on their buffer settings they have also to be TABLEUPDATEd().

p.s. I nowhere found a hint that a view buffering could be set to 1 (NO buffering)

MarK

RE: Can you edit grid?

You set the buffering of the view in the form's data environment. With row buffering, as the user navigates the grid, any changes are sent to the table. With table buffering, you'd want to tableupdate after leaving the grid or in a save button.

Mike Yearwood - Former FoxPro MVP

RE: Can you edit grid?

Hi Mike,

Quote:


With row buffering, as the user navigates the grid, any changes are sent to the table.

That's true up to the last row. You'll either have to move up one row or call TABLEUPDATE() when leaving the grid. And I know from my experience that it is almost impossible to make a user move up one row when having reached the last one, usually moaning "Why is it not saved?"

MarK

RE: Can you edit grid?

In addition to the points made by Mike (Yearwood) and Mark, when I talked about a view being able to update a table "provided the settings are right", I was thinking of the settings on the Update Criteria tab of the view designer, or their equivalents in CURSORSETPROP(). Things like WhereType, SendUpdates, UpdatableFieldList and UpdateNameList.

But to go back to the original questionm, the easiest way to edit a grid is to edit the underlying table.

Mandy, we haven't heard back from you since you started this thread. Were our answers any use to you?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Can you edit grid?

(OP)
Hi Mike, mark yearwood and everyone... thank you for all your answers... im still studying all your inputs so that i could use it to my project and to my future projects... thanks and God bless...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close