RE: Deleting rows from DataGrid
v-jetan_at_online.microsoft.com
Date: 03/07/04
- Next message: Christian Kuendig: "Re: AcceptChanges on Rows.Find metod"
- Previous message: harry: "Re: Exception trying to bind to TrackBar - Can one bind a TrackBar?"
- In reply to: Jacek Hełka: "Deleting rows from DataGrid"
- Next in thread: Jacek Hełka: "Re: Deleting rows from DataGrid"
- Reply: Jacek Hełka: "Re: Deleting rows from DataGrid"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 07 Mar 2004 08:49:06 GMT
Hi Jacek,
Thank you for posting in the community!
Based on my understanding, you want to intercept into the "delete" key
press process, and do prompt for the user.
====================================
I think you can intercept the "delete" key's keydown and keyup event of
datagrid, then do your prompt.
To achieve this, you should inherit from the datagrid class, then override
the WndProc method, at last, you should intercept the WM_KEYDOWN and
WM_KEYUP message.
During I am writing the sample code, I found that it seems that WinForm
datagrid control has already intercept into the "delete" key message. So if
you just override the WndProc method, you can not intercept it.
So you should also override ProcessCmdKey method, force the datagrid to
forward the "delete" key message to the WndProc. Like this:
private int WM_KEYDOWN=0x100;
private int WM_KEYUP=0x101;
private int VK_DELETE=0x2e;
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
Keys keyCode = (Keys)(int)msg.WParam & Keys.KeyCode;
if((msg.Msg == WM_KEYDOWN || msg.Msg == WM_KEYUP) && keyCode ==
Keys.Delete )
{
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
protected override void WndProc(ref Message m)
{
if((m.Msg ==WM_KEYDOWN || m.Msg ==WM_KEYUP ) && m.WParam.ToInt32()
==VK_DELETE )
{
MessageBox.Show("you pressed delete!");
return;
}
base.WndProc (ref m);
}
For these constant values in the code, you can figure it out through a tool
named APIviewer followed by VB6.0.
=======================================
Please apply my suggestion above and let me know if it helps resolve your
problem.
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
- Next message: Christian Kuendig: "Re: AcceptChanges on Rows.Find metod"
- Previous message: harry: "Re: Exception trying to bind to TrackBar - Can one bind a TrackBar?"
- In reply to: Jacek Hełka: "Deleting rows from DataGrid"
- Next in thread: Jacek Hełka: "Re: Deleting rows from DataGrid"
- Reply: Jacek Hełka: "Re: Deleting rows from DataGrid"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|