|
-
May 24th, 2005, 09:32 AM
#1
Thread Starter
Frenzied Member
Key Down Event on a DataGrid
I am trying to add a KeyDown event for a datagrid, specifically to catch the Delete key to Delete the row of data. The DataGrid is set to ReadOnly, but it seems like half the time I press Delete the row tries to go into edit mode and the event never fires. Anybody have any idea what would cause this? Here's the event code:
Private Sub dgMaintenance_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles dgMaintenance.KeyDown
Dim mbrResult As MsgBoxResult ' Confirmation result
Dim boolResult As Boolean ' Delete result
' If a row is selected
If e.KeyCode = Keys.Delete And dgMaintenance.CurrentRowIndex > -1 Then
' Confirm they want to do this
mbrResult = MsgBox("Are you sure you wish to delete this Scheduled Maintenance?", _
MsgBoxStyle.YesNo, "Warning! Scheduled Maintenance Deletion")
' If Deletion is confirmed
If mbrResult = MsgBoxResult.Yes Then
' Attempt to Delete this Scheduled maintenance
boolResult = oNRS_SQL.DeleteMaintenanceRecord(dgMaintenance.Item(dgMaintenance.CurrentRowIndex, 0))
' If Deletion is not successful
If boolResult = False Then
' Pop an error message
MsgBox("Unable to delete Scheduled Maintenance", MsgBoxStyle.Critical, "Database Error")
Else
' Reload the Maintenance schedule
oNRS_SQL.LoadMaintenanceSchedule(m_intResourceID)
End If
End If
End If
End Sub
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Aug 4th, 2005, 12:52 PM
#2
Member
Re: Key Down Event on a DataGrid
Hi,
I have the same problem!! Did you get any help on this issue? I'm trying to get a confirmation from the user before deleting a row. Any idea? Thanks.
-
Aug 22nd, 2005, 09:10 AM
#3
Frenzied Member
Re: Key Down Event on a DataGrid
what about this, i have asked these questions before and my fellows here have helped me.
check this thread, i was the one who started it so you might rate me for directing it again to you . it took me a couple of minutes to find it in the site, you should search the forums before making new threads
anyway here is the link
the same thread asked by Me
hope you like it
rgds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|