Re: Deleting rows from DataGrid
From: Jacek Hełka (Jacek.Helka_at_potis.com.pl)
Date: 03/09/04
- Next message: Rajesh Patel: "Re: how to update data from textboxes using the sqldataadapter wizard?"
- Previous message: Miha Markic [MVP C#]: "Re: DataFormatString."
- In reply to: v-jetan_at_online.microsoft.com: "RE: Deleting rows from DataGrid"
- Next in thread: v-jetan_at_online.microsoft.com: "Re: Deleting rows from DataGrid"
- Reply: v-jetan_at_online.microsoft.com: "Re: Deleting rows from DataGrid"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 9 Mar 2004 13:45:15 +0100
Thank you.
This is quite complicated way, but i think, that it will work good.
Regards,
Jacek.
"""Jeffrey Tan[MSFT]""" <v-jetan@online.microsoft.com> wrote in message
news:z6nZVECBEHA.564@cpmsftngxa06.phx.gbl...
> 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: Rajesh Patel: "Re: how to update data from textboxes using the sqldataadapter wizard?"
- Previous message: Miha Markic [MVP C#]: "Re: DataFormatString."
- In reply to: v-jetan_at_online.microsoft.com: "RE: Deleting rows from DataGrid"
- Next in thread: v-jetan_at_online.microsoft.com: "Re: Deleting rows from DataGrid"
- Reply: v-jetan_at_online.microsoft.com: "Re: Deleting rows from DataGrid"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|