PC Review


Reply
Thread Tools Rate Thread

Undo a delete in a datagridview

 
 
=?Utf-8?B?QXVzY2xhZA==?=
Guest
Posts: n/a
 
      18th Oct 2006
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?QXVzY2xhZA==?=
Guest
Posts: n/a
 
      18th Oct 2006


"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.
 
Reply With Quote
 
Norman Chong
Guest
Posts: n/a
 
      18th Oct 2006

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?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot undo delete peter Microsoft Outlook Discussion 1 23rd Feb 2007 08:26 AM
Undo deletions in DataGridView Michael A. Covington Microsoft C# .NET 2 16th Jun 2006 05:55 AM
undo delete =?Utf-8?B?ZW55YXc=?= Microsoft Excel Programming 2 9th Jun 2006 10:52 AM
Refreshing datagridview contents after a failed delete in bound datagridview Bob Microsoft VB .NET 0 5th Jan 2006 07:34 PM
Undo Delete =?Utf-8?B?RmVlbGluZyBsZXNzIHRoYW4gYnJpZ2h0?= Microsoft Access 1 3rd Dec 2004 09:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:09 PM.