Groups | Blog | Home
all groups > vb.net data > september 2005 >

vb.net data : Force update a Datagrid


PaulNaude
9/30/2005 4:29:02 AM
I have a parent and a child datagrid, both linked to tables in a dataset with
the appropriate relationship.

If I add a new record in the parent table and then click directly in the
child table (which at this stage have no records), I can add a child value
but the parent value is NULL.
If I first change the selection in the parent table, off the new record and
then back to the new record, I can click in the child table and the parent
record is automatically updated.

This changing of row selection in the parent table after creating a new
record is however a nuisance for the user (and me!).

Jim Underwood
11/3/2005 1:23:21 PM
I hvae nto tried this, but it sounds like the new row does not register as
complete until you select another row. There are probably other focus
events that will register the row as complete, but you dont need to worry
about them at the moment.

Create an event that triggers when the datagrid loses focus. Select a
different row, or no row, then reselect the row the user just updated. This
should trigger the new row so it registers with the child table.


[quoted text, click to view]

PaulNaude
11/3/2005 9:56:01 PM
Thanks Jim

One reason I tried not to use your suggested method was to elimanate
possible infinte loops since I have code running when the current cell
changes. I supose I could use flags and stuff to prevent this when a new row
is entered but I just hoped that there was a 'neater' way!

I ended up deleting the relationships and replaced them with 'fake' ones by
using the dataview filter for the child grid, and ended up entering a copy of
the parent record into the child's parent column, each time a row change
event fires (regardless of whether it is a new or existing row).

It was a long way to success but at least it worked!

Thanks again for you feedback.

[quoted text, click to view]
AddThis Social Bookmark Button