Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

What is the best way to delete a row from a grid?

462 views
Skip to first unread message

Sharon Klas

unread,
Mar 18, 2000, 3:00:00 AM3/18/00
to
I would like the user to be able to select the row, or rows that they
would like to delete, then click a button to delete the selected
row(s). This is new to me in VFP. Can somebody point me to directions
as to how to do this?

The grid is bound to a query that is drawng data fro many tables if that
makes a diference.

Thanks in advance.


Michael Lenoir

unread,
Mar 19, 2000, 3:00:00 AM3/19/00
to
Sharon,

Your question is not clear. Do you want to delete the rows in the grid or do
you want to delete the data in the underlying tables?

My suggestion would be to query the source data into a temporary TABLE,
adding a new logical field l_display. Then, base your grid on a query from
your TEMPORARY table, retrieving only the records where l_display = .t.

When the user marks records in the grid and selects delete, the key fields
from your selected records can be looked-up in your temporary table and the
l_display field can be changed to .f. Then, issuing a grid.requery() will
refresh the grid from your temp table, with only the selected records
showing.

Hope this helps.

--
Michael Lenoir
Matrix Solutions, Inc.
mi...@matrixsolutions.com

Sharon Klas <sk...@escape.ca> wrote in message
news:38D3B2FE...@escape.ca...

Guy

unread,
Mar 19, 2000, 3:00:00 AM3/19/00
to
On Sat, 18 Mar 2000 11:46:54 -0500, Sharon Klas wrote
(in message <38D3B2FE...@escape.ca>):

Sharon

If you would like to keep it simple, consider this;

Assign a Click event of the header column a statement something like this.

WITH ThisForm
.Grid.Column1.Visible = .F
.Grid.Column1.Width = 0
.Refresh()
ENDWITH

This will hide Column1 when the header button is clicked. You may also want
to include a reset button on the form as well.

I also use the header as a command button to set a filter or switch an index
to change the sort order.

Hope this helps.

Sharon Klas

unread,
Mar 19, 2000, 3:00:00 AM3/19/00
to
Thanks for your reply Michael.

I need to delete the underlying data. I am looking for a method that gives me
the vales of each of the columns for the selected row in the grid. That way I
can create a query to delete the underlying data.

Thisform.grid.value always returns 0. I need a method that returns the values
for each column in the row that was selected. If you know of a method, please
let me know.

Thanks

Michael Lenoir wrote:

> Sharon,
>
> Your question is not clear. Do you want to delete the rows in the grid or do
> you want to delete the data in the underlying tables?
>
> My suggestion would be to query the source data into a temporary TABLE,
> adding a new logical field l_display. Then, base your grid on a query from
> your TEMPORARY table, retrieving only the records where l_display = .t.
>
> When the user marks records in the grid and selects delete, the key fields
> from your selected records can be looked-up in your temporary table and the
> l_display field can be changed to .f. Then, issuing a grid.requery() will
> refresh the grid from your temp table, with only the selected records
> showing.
>
> Hope this helps.
>
> --
> Michael Lenoir
> Matrix Solutions, Inc.
> mi...@matrixsolutions.com
>
> Sharon Klas <sk...@escape.ca> wrote in message
> news:38D3B2FE...@escape.ca...

Nancy Folsom (FoxPro MVP)

unread,
Mar 19, 2000, 3:00:00 AM3/19/00
to
"Sharon Klas" <sk...@escape.ca> wrote in message
news:38D5A92F...@escape.ca...

> Thanks for your reply Michael.
>
> I need to delete the underlying data. I am looking for a method that
gives me
> the vales of each of the columns for the selected row in the grid. That
way I
> can create a query to delete the underlying data.
>
> Thisform.grid.value always returns 0. I need a method that returns the
values
> for each column in the row that was selected. If you know of a method,
please
> let me know.

Sharon-

The record pointer in the recordsource of the grid will be pointing to the
information.

But, is there a reason why you can't just use the deleted mark of the grid?

0 new messages