Hi,
I am trying to Delete a Row with the Delete Key from the KeyDown event. I have the DeleteKeyAction set to Delete Selected Rows (but have tried all 4 options) and I have RowSelection set to single but also tried multiple.
My problem is that the KeyDown event will only fire if I select a cell. It does not fire when I just have a row selected. I've included my grid loading and keydown event code.
Private Sub idgQuotesDetail_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles idgQuotesDetail.Loaded Me.idgQuotesDetail.SelectionSettings.RowSelection = Infragistics.Silverlight.SelectionType.Single Me.idgQuotesDetail.SelectionSettings.CellSelection = Infragistics.Silverlight.SelectionType.Single Me.idgQuotesDetail.RowSelectorSettings.Visibility = Windows.Visibility.Visible Me.idgQuotesDetail.DeleteKeyAction = Infragistics.Silverlight.DeleteKeyAction.DeleteSelectedRows Me.idgQuotesDetail.EditingSettings.AllowEditing = Infragistics.Silverlight.EditingType.Cell Me.idgQuotesDetail.EditingSettings.IsMouseActionEditingEnabled = Infragistics.Silverlight.MouseEditingAction.SingleClick Me.idgQuotesDetail.PagerSettings.AllowPaging = Infragistics.Silverlight.PagingLocation.Bottom Me.idgQuotesDetail.PagerSettings.PageSize = 6 Me.idgQuotesDetail.SortingSettings.AllowSorting = True Me.idgQuotesDetail.SortingSettings.AllowMultipleColumnSorting = True End Sub
Private Sub idgQuotesDetail_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Input.KeyEventArgs) Handles idgQuotesDetail.KeyDown Select Case e.Key Case Key.Insert AddNewQuoteDetail() Case Key.Delete DeleteCurrentRow() End Select End Sub
Is this a bug or am I missing something?
Thanks,
Lisa.
Hi Lisa,
I was hoping for a simplified sample that i could run to see what was happening
I've attached a sample that shows row deleting working. Note: as with your code snippets, you must click on a row selector in order to select a row.
-SteveZ
Hi Steve,
I included some code above in my first post. The Key Down event does not fire at all if I just have the row selected. If I select a cell then it fires and executes the delete.
I've attached my xml and xml.vb code.
The RowDeleteing event isn't firing when you press the delete key when a row is selected?
Do you have a sample that shows this? I tried it out, and everything appears to be working.
Well we have to run some validations to confirm that the row is allowed to be deleted but it doesn't even get there. The problem is that the event wont fire. It works fine if I select a cell and then press the delete key.
From the code you provided it seems like you are trying to delete the row on your own when the "Delete" key is pressed. However, when you set DeleteKeyAction, the Grid automatically removes the corresponding rows based on your DeleteKeyAction setting.
Could you try if this will work for you?
This might be related to the fact that the event is not firing, but we will look further in that, it might be an issue.
HTH,