By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,681 Members | 1,338 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,681 IT Pros & Developers. It's quick & easy.

Datagrid Row Delete Detection

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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" <st******@mail.ucf.edu> wrote in message
news:00****************************@phx.gbl...
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


Nov 20 '05 #2

P: n/a
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

Nov 20 '05 #3

P: n/a
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]" <ab*@online.microsoft.com> wrote in message
news:Xa**************@cpmsftngxa06.phx.gbl...
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


Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.