Link to home
Start Free TrialLog in
Avatar of AMLabels
AMLabels

asked on

Deleting DataGridViewRow with Underlying DataRelation

Hi,

I have a DataGridView which is populated from a DataTable that has a foreign key constraint linking it to another DataTable.

When I delete a row in the DataGridView that the second DataTable depends on, the DataError event is fired because the deletion will cause orphan rows in the second DataTable.

Is there any way to delete/remove a row from the DataGridView (rendering it not visible to the user) without deleting it in the underlying DataTable?

This would be useful becuase I never want to physically delete records, but rather to set a boolean flag indicating it as deleted.

Thanks.
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Me.DataGridView1.Rows(0).Visible = False

Bob
Avatar of AMLabels
AMLabels

ASKER

I tried setting the row visible to false, but the application throws an error stating that the operation was not allowed in the current context.
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Not a good enough answer?  Did you manage to do something else?  What was your final solution?

Bob