472,093 Members | 2,500 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,093 software developers and data experts.

DataGridView deleting multiple rows

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

Jul 18 '06 #1
3 10594
"manjub" <ms****@gmail.coma écrit dans le message de news:
11*********************@s13g2000cwa.googlegroups.c om...

| 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

--
Joanna Carter [TeamB]
Consultant Software Engineer
Jul 18 '06 #2
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):
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

From - Tue
Jul 18 '06 #3
Thanks a lot for your help. It worked great.

Manju

nvx wrote:
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):
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

From - Tue
Aug 9 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Robert Brown | last post: by
6 posts views Thread by =?Utf-8?B?TU1TSkVE?= | last post: by
2 posts views Thread by Michael | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.