DataGridView deleting multiple rows

M

manjub

Hi,

I am trying to add ability to delete multiple rows from a DataGridView
in my application. When user selects multiple rows and presses delete
button, I want to show a message asking to user to confirm delete. I am
using UserDeletingRow event.

My problem is that if 5 rows are, 5 different events are triggered. If
I handle UserDeletingRow, I will have to ask for user's confirmation 5
times. Is there any way to avoid this and ask for confirmation only
once.

Thanks in advance for your help,

Manju
 
J

Joanna Carter [TeamB]

"manjub" <[email protected]> a écrit dans le message de (e-mail address removed)...

| I am trying to add ability to delete multiple rows from a DataGridView
| in my application. When user selects multiple rows and presses delete
| button, I want to show a message asking to user to confirm delete. I am
| using UserDeletingRow event.
|
| My problem is that if 5 rows are, 5 different events are triggered. If
| I handle UserDeletingRow, I will have to ask for user's confirmation 5
| times. Is there any way to avoid this and ask for confirmation only
| once.

The problem with so many uses of DataGridView is that people forget that it
was intended to be a UI component displaying data that is not held in the
grid.

If your data is held in either a list or table, then the answer is to remove
the items from the list or table, then the grid will update to reflect the
changes in the underlying data.

Joanna
 
N

nvx

You may use KeyPress event instead of UserDeletingRow. Detect if DEL was
pressed and if there are any rows selected. If so, delete all these rows
with foreach statement.

With regards
nvx


manjub napsal(a):
 

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