Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Capture the Delete Key?
Message
 
À
14/08/2006 12:37:03
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Versions des environnements
Environment:
VB.NET 1.1
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
01144609
Message ID:
01145370
Vues:
22
I'm not executing the MyBase.ProcessCmdKey() method. If you notice in my code, I only execute it when the user respond "Yes" to the delete command. Problem is, even when I hot "No", the row disappears.

>Ben,
>
>Don't execute the base.ProcessCmdKey() method when you don't want it to do it's default processing.
>
>~~Bonnie
>
>
>
>>Ok, I created a subclass of the original DataGrid control and I added the following code ...
>>
>>
>>    Protected Overrides Function ProcessCmdKey(ByRef Msg As Message, ByVal KeyData As Keys) As Boolean
>>        '************************************************************************
>>        ' Procedure/Function: ProcessCmdKey()
>>        ' Author: Ben Santiago
>>        ' Created On: 08/14/2006
>>        ' Description:
>>        '       Capture and process "special" keys.
>>        '************************************************************************
>>
>>        '***************************************
>>        ' Define Constants
>>        '***************************************
>>        Const WM_KEYDOWN As Integer = &H100
>>        Const WM_SYSKEYDOWN As Integer = &H104
>>
>>        '***************************************
>>        ' Initialize Variables
>>        '***************************************
>>        Dim intAnswer As MsgBoxResult
>>
>>        '***************************************
>>        ' Process Key Pressed
>>        '***************************************
>>        If ((Msg.Msg = WM_KEYDOWN) Or (Msg.Msg = WM_SYSKEYDOWN)) Then
>>            Select Case (KeyData)
>>                Case Keys.Delete
>>                    '***************************************
>>                    ' Query User To Confirm Row Delete
>>                    '***************************************
>>                    If Me.IsSelected(Me.CurrentRowIndex) Then
>>                        intAnswer = MessageBox.Show("Are you sure you want to delete the selected record?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
>>                        If intAnswer = MsgBoxResult.Yes Then
>>                            '***************************************
>>                            ' Send Keys To Base Function For Processing
>>                            '***************************************
>>                            Return MyBase.ProcessCmdKey(Msg, KeyData)
>>                        End If
>>                    End If
>>            End Select
>>        End If
>>    End Function
>>
>>
>>Now, I am able to capture the Delete Key appropriately, which is great, but the problem is that the row is still removed from the grid. How do I stop the grid from removing the row?
________________________
Ben Santiago, MCP & A+
Programmer Analyst (SQL, FoxPro, VB, VB.Net, Java, HTML, ASP, JSP, VBS)
Eastern Suffolk BOCES - Student Data Services


Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
-Rich Cook
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform