PC Review


Reply
Thread Tools Rate Thread

Datagrid Row Delete Detection

 
 
Mike
Guest
Posts: n/a
 
      14th Oct 2003
Hi,

I am working with the data in the datagrid behind the
scenes because I have very specific data validation that
needs to be done before saving to the database.

I am wondering, what event detects when the user
highlights a row and then hits "Delete" button. I have
tried the keypress event, but that doesn't work.

Thank you,

Mike
 
Reply With Quote
 
 
 
 
Dmitriy Lapshin [C# / .NET MVP]
Guest
Posts: n/a
 
      14th Oct 2003
Hi Mike,

I'm afraid you'll have to inherit from the DataGrid and override its WndProc
to handle the Del key upon WM_KEYDOWN notifications. You can also try
overriding ProcessDialogKey not to deal with raw Win32 API messages but I am
not sure this will help.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Mike" <(E-Mail Removed)> wrote in message
news:00d601c39264$1bf93e50$(E-Mail Removed)...
> Hi,
>
> I am working with the data in the datagrid behind the
> scenes because I have very specific data validation that
> needs to be done before saving to the database.
>
> I am wondering, what event detects when the user
> highlights a row and then hits "Delete" button. I have
> tried the keypress event, but that doesn't work.
>
> Thank you,
>
> Mike


 
Reply With Quote
 
Aiwen Guo [MSFT]
Guest
Posts: n/a
 
      11th Nov 2003
Hey,

If your Datagrid is bound to a dataset, you can use the Dataset's
Row/Column changing events to do the validation code:

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemdatadatatableclassrowdeletingtopic.asp

http://msdn.microsoft.com/library/de...us/vbcon/html/
vbtskvalidatingdataduringrowchanges.asp

You can add your validation code to the DataTable.RowDeleting event, and
make sure you delete the right row.

Hope it helps.

Aiwen
VB.Net Team

 
Reply With Quote
 
Dmitriy Lapshin [C# / .NET MVP]
Guest
Posts: n/a
 
      12th Nov 2003
Aiwen,

I remember there were issues with that way of validation related to
cancelling an action when it was not valid. Something like the RowDeleting
event had been cancelled but the corresponding row disappeared from the grid
anyway (but remained intact in the DataTable).

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Aiwen Guo [MSFT]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hey,
>
> If your Datagrid is bound to a dataset, you can use the Dataset's
> Row/Column changing events to do the validation code:
>
>

http://msdn.microsoft.com/library/de...us/cpref/html/
> frlrfsystemdatadatatableclassrowdeletingtopic.asp
>
>

http://msdn.microsoft.com/library/de...us/vbcon/html/
> vbtskvalidatingdataduringrowchanges.asp
>
> You can add your validation code to the DataTable.RowDeleting event, and
> make sure you delete the right row.
>
> Hope it helps.
>
> Aiwen
> VB.Net Team
>


 
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
CheckBox unchecked status detection in DataGrid Template Column Javier Microsoft ASP .NET 2 12th Dec 2005 05:16 PM
DataGrid double-click detection mdb Microsoft C# .NET 1 9th May 2005 11:30 PM
Delete Event when pressing delete in a datagrid? Lars Netzel Microsoft VB .NET 2 20th Jan 2005 02:38 PM
Delete mutiple rows in a dataGrid using delete Key =?Utf-8?B?TVZC?= Microsoft Dot NET Framework 0 26th Oct 2004 04:39 AM
Re: .exe Virus detection, but can't delete it? Carey Frisch [MVP] Windows XP Security 0 27th Jul 2004 06:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:06 AM.