This is a migrated thread and some comments may be shown as answers.

Simulate user delete row action programmatically

1 Answer 253 Views
GridView
This is a migrated thread and some comments may be shown as answers.
hermann
Top achievements
Rank 1
hermann asked on 25 Aug 2011, 04:46 PM
Hi,
a have a RadGridView with a bound ObservableCollection datacontext.
When the user selects a row and pushes the Delete key, the row disappears and the Deleted event is fired.
I have a menu item as well which allows to delete the selected row programmatically,
but when I call mygrid.Items.Remove(myselectedrow.DataContext) the row disappears, but the Deleted event is not triggered.
How can I get the grid to fire the Deleted event when removing a  row programmatically as well?

Is it something like
mygrid.RaiseEvent(new RoutedEventArgs(RadGridViewEvents.DeleteRow, my_row));
?
Thank you,
Bye

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 26 Aug 2011, 12:39 PM
Hello Hermann,

The Deleting/ Deleted events will be fired on invoking the Delete command, not when an item is removed from the source collection. What you may try to do is to implement directly the built-in Delete command:

<telerik:RadContextMenu.ContextMenu>
                <telerik:RadContextMenu >
                    <telerik:RadMenuItem Header="delete" Command="telerik:RadGridViewCommands.Delete" CommandParameter="{Binding SelectedItem}" />
                </telerik:RadContextMenu>
            </telerik:RadContextMenu.ContextMenu>

Let me know whether this approach will fit into your requirements. 

Regards,
Maya
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
GridView
Asked by
hermann
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or