DataGridView UserDeletingRow

G

Guest

Hi,

Is it possible to do the following, and if so, how?

In a datagridview, assume I highlight 10 rows and press the Delete key.
Upon doing so, I'd like to do the following:

Collect the Row information for each of the 10 highlighted rows marked
for deletion, pass them to a new form where the user will confirm that they'd
like to actually delete them from the database and show these rows in a
"Confirmation" (separate) datagridview. The UserDeletingRow event and
UserDeletedRow fires for each row; I need to perform this action per block of
rows and not individually.


Regards,

Giovanni
 
G

gordonfmoore

Did you get an answer to this? Especially about intercepting the delete
key so that you can process the selected rows?

Regards Gordon.
 
G

gordonfmoore

Okay in the mydatagridview_UserDeletingRow event

private void mydatagridview_UserDeletingRow(object sender,
DataGridViewRowCancelEventArgs e)

you can look at the e.Row.Selected flag and if you want to know what
row you are on

MessageBox.Show("Current Row = "+
e.Row.Cells["myfield].Value.ToString());

The deleting event gets called for each row selected (from top to
bottom). If you want to cancel the event use e.Cancel and return in
some if statement.

Just want to say that this datagridview is so much better than the old
one - well done MS (for a change).

Regards
Gordon
 

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

Top