473,440 Members | 1,643 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,440 software developers and data experts.

how to capture the event that someone press a 'del' key when highlight a row in a datagrid?

I would like to have a datagrid that can be edited but not delete...
and I have no idea how to capture the del key press event.
Please help, thank!
Nov 17 '05 #1
1 2690
Hi YWChan,

one was to do this is to use the DataGrid as a subclass and then override
the ProcessCmdKey method, for example:

class MyDataGrid : DataGrid
{
public MyDataGrid() : base()
{
}

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if(keyData == Keys.Delete)
{
//do processing for delete

//return true to stop the event being raised and deleting
return true;
}

return base.ProcessCmdKey(ref msg, keyData);
}
}
Hope that answers your question to some level.

Mark.

"ywchan" wrote:
I would like to have a datagrid that can be edited but not delete...
and I have no idea how to capture the del key press event.
Please help, thank!

Nov 17 '05 #2

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

Similar topics

7
by: Hans | last post by:
Hi! Does anybody of you have a good algorithm to capture when a value in a textbox is changed? I'm using the keypress/keydown events but they seems to be a bit inconsistent (IE and Mozilla)....
1
by: Pedro Graca | last post by:
Well ... I've been using Windows for a long time before I switched to Linux. I'm very used to type CTRL-ALT-DEL everytime I'm leaving my computer or arriving to it. It's hapenned _twice_ (in the...
1
by: Matthew Wieder | last post by:
Hi - I wanted to capture the enter button on a form since I have a datagrid with the first column being a delete button and if someone hits enter it deletes the first record. I coded: private...
10
by: Tim Frawley | last post by:
I am attempting to detect a Shift+Tab in the KeyPress event for back navigation on a control that doesn't support this method. Does anyone have any ideas how to compare e.KeyChar to a ShiftTab? ...
7
by: Bob Achgill | last post by:
When I use the code for KeyPress to capture pressing a certain key for processing on a form with no Text Box it works. But when I try the same code on my application that has text boxes it does...
0
by: LCH | last post by:
hi i would like to know how to capture a datagrid keypress event. I have form contains of a datagrid with 5 rows and 5 colums and a button. When i press on the enter button at the last row n...
0
by: crferguson | last post by:
I've been looking in every place I can to find a solution for this and I believe I've pieced a solid one together so I thought I'd share since I've found so much help on these groups... This is...
10
by: amiga500 | last post by:
Hello, I have one basic simple question. When I have multiple records in the datagrid as follows: Code Product 1 Product 2 Product 3 11111 A B C...
1
by: anil | last post by:
I want to capture key down event in the window service and open a new app when the user press F7. Is there any solution available in C#
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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
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...
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.