473,574 Members | 2,690 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 10718
"manjub" <ms****@gmail.c oma écrit dans le message de news:
11************* ********@s13g20 00...legro ups.com...

| 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
5665
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 = 'XYZ'"
5
3755
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. When I do a "select" for the records, I load them into a dataset, use an "insert" statement to insert the info into the second table (by a for...
4
11475
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;"; $result=mysql_query($sql) or die ("<br> Could not Retrieve Data <br>"); $num_rows=mysql_num_rows($result); While ($row =mysql_fetch_array($rs))
2
1807
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 dsPar.GetChanges(DataRowState.Deleted) dsPar.Tables(0).DefaultView.Delete(dgDelete.CurrentCell.RowNumber) command = New...
5
1899
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 delete... click delete.. it shows deleted records then you can go back to the screen, It works if one record is selected but any more it doesnt delete...
6
8432
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 fill it: MyTableTableAdaptor.fill(MyDataset.Mytable);
2
5326
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 what hotmail web UI is doing now (having the option of selecting multiple rows (using the checkbox provided) and perform a set of operations on them)
3
3911
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 messing up. Problems:
6
4129
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 have my first datagridview to have a multi-select (which i have currently), but what i want to happen when multiple rows are selected is different. I...
0
8063
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7822
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8101
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5302
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3742
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2249
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1347
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1062
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.