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.
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,
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.
Hi Steve,
Thanks for your code. I pared mine down to duplicate yours and the only way I could get it to work was to put my code in the MainPage as yours is, using the User Control. Mine is in a Navigation Page using the Page Control.
Can you please test in a Navigation Page to confirm whether or not the control is the problem?
Thanks!
Will you have a chance to look at this soon? My only option now is to add a delete checkbox to my grids and since I need to bring this project to a close I have to make that decision soon.
Hi guys,
Is anyone going to look into this?
Hi Lisa,
I apologize i was away on vacation.
However, i wasn't able to reproduce your issue with a Navigation Page.
Do you have a sample that you're using that you can send?
-SteveZ
Vladimir responded through my support request. The problem is with the scroll viewer controlling the mousebutton event.
I was able to resolve the problem by calling the OnMouseLeftButtonDown handler in my page containing the grid and set e.handler to true.