473,407 Members | 2,598 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,407 software developers and data experts.

Undo a delete in a datagridview

Using a DatagridView in .net 2.0

How would you go about implementing an "undo" event?

So if the user selects a row in the datagridview, then hits the delete key,
I handle the deletion by using the "datagridviews.rows.removeat" function.

This removes the row from the datagridview, but the row should still be
available because I have not yet committed the change to the database.

Is there a simple property or method I can use to make the row visible again?

thanks
Oct 18 '06 #1
2 4220


"Ausclad" wrote:
Using a DatagridView in .net 2.0

How would you go about implementing an "undo" event?

So if the user selects a row in the datagridview, then hits the delete key,
I handle the deletion by using the "datagridviews.rows.removeat" function.

This removes the row from the datagridview, but the row should still be
available because I have not yet committed the change to the database.

Is there a simple property or method I can use to make the row visible again?

thanks

I don't know if this is the correct way to do it...but I managed to get what
I wanted by doing the following..

For the datasource (in my case a datatable), I called the "RejectChanges"
method and then with the bindingsource, i called "resetbindings"

this reset the status of the deleted row, then reset the datagridview so
that the value was now showing again.
Oct 18 '06 #2

Ausclad schrieb:
>
How would you go about implementing an "undo" event?

Hi Ausclad,

Don't know if it's what your looking for (Or if it's the best way...):
Store the complete row(s) you want to delete within a private
DataGridViewRowCollection before deleting them. When you click on your
'Undo' - Button or whatever, you can raise your event which should then
pump the deleted values into the grid.

Does that help?

Oct 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jay | last post by:
I need to implement an undo and redo for an entire row in a listview containing approximately 10 columns. I'm not sure of the best way to implement this. The only thing that I've thought of is a...
18
by: Darryl Kerkeslager | last post by:
I don't do much with subforms - in fact I've deliberately avoided them - but .... I have a tab control that will contain several subforms, each bound to a separate table, and each table/subform...
2
by: Leslie | last post by:
On a form, I create a record and save, and am ready to enter another. I decide to Quit the form which executes an "Undo" in case there is data entered. This then tries to "delete" my just saved...
0
by: Bob | last post by:
I have relational integrity set up in my sql server 2005 database that prevents cascading deletes in some cases. I'm using a bound datagrid view and a tablenavigator. When I click the delete...
2
by: Michael A. Covington | last post by:
Any thoughts about how best to implement "undo most recent deletion" in a DataGridView in which the user is allowed to delete rows (but not edit their contents)? Is it as simple as stashing a...
5
by: Steve | last post by:
I have created my own context menu. Everything works except undo'ing deleted text. My code for these two events are: Private Sub tsmiUndo_Click(ByVal sender As Object, ByVal e As...
4
by: =?Utf-8?B?UmljaA==?= | last post by:
On a form - I have a datagridview which is docked to the entire form. The datagridview allows users to Delete and/or Add Rows. On the Form_Load event I Fill the datagridview source table with a...
1
by: anupam roy | last post by:
Hi All, I want to perform basic Edit menu functionalities on my custom design surface. While all the Cut/Copy/Paste/Deelete/Select functionalities working fine with code below,Undo/Redo standard...
2
by: tanuja5 | last post by:
hi.. how to delete the selected row in datagridview using ContextMenuStrip.When i right-click and press "delete" the seleted row in the dataGridView has to be deleted and as well in my access...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.