473,325 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 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 10689
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: patrick.mcdonald | last post by:
Hello, Example: I have 100 rows that all have the field vaule of 'XYZ' I would like to delete only 10 of those rows. Is there such a query like "Delete 10 rows from table where table.field...
5
by: Robert Brown | last post by:
Hi All. I have a routine that checks a SQL Table for all records 3 months prior to a predetermined date, then I insert them into an Archive DB then delete those records from the original table....
4
by: arizal | last post by:
Hi , I am trying to figure out why my PHP code to delete multiple value by selecting the checkbox is not working. My php code is listed as below <?php $sql = "Select * from list;";...
2
by: onlyGirl | last post by:
How could you delete multiple rows in a datagrid? This is what I have so far For Each row In dsPar.Tables(0).Rows rowIndex = dgDelete.CurrentCell.RowNumber ...
5
by: jasone | last post by:
Hi all, im nearly there with this one and im sure it shouldnt be hard to solve, i just cant seem to find the solution. ive got records being displayed, the user can then tick what records to...
6
by: =?Utf-8?B?TU1TSkVE?= | last post by:
How to let user delete multi rows from the BindingSource while the SelectionMode Property set to RowHeaderSelect I have in my program datagridview bound it to sql table Throw Bindingsource To...
2
by: Michael | last post by:
It seems that a gridview allows us to delete only a single row at a time. How to extend this functionality to select multiple rows and delete all of the selected rows in a single stroke? just like...
3
by: nigelesquire | last post by:
Please help! I'm trying to clone and delete multiple rows with JavaScript. I need two delete buttons that work...! I only have one for now, but it's not working properly, the output count is...
6
by: Gun Slinger | last post by:
Hi guys, I have a quick question which i have pondered for a little while. I'm not sure if its even a good idea (so maybe advice on whether or not to do it would be helpful as well). I want to...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.