Is there a need to Cancel an AddNew for an unused DataRowView

  • Thread starter Thread starter lee.ottaway
  • Start date Start date
L

lee.ottaway

I'm using the following code to open a form and pass it a DataRowView
for modification:

row = dv.AddNew()
frm.DataRowView = row
frm.ShowDialog()

My question is, if the user presses the cancel button in the form
dialogue is it necessary to perform a mrv.CancelEdit (where mrv is of
course the DataRowView held at module level) or is it sufficient just
to exit the form using DialogResult.Cancel and then disposing of the
form?

I'm asking because I don't want to have redundant rows left hanging
around in memory waiting to cause problems.

Thanks
 
Hi,

I do not think CancelEdit will remove the row from the DataTable/DataView.
It suppose to cancel editing, but you will have an empty row. You would need
to call RejectChanges of the DataTable and it will roll back all the changes
to it
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top