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

UserDeletingRow sender

1 Answer 185 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nadia Sangiovanni
Top achievements
Rank 1
Nadia Sangiovanni asked on 09 Jul 2012, 02:43 PM
Hi Support,

Is there a way to know if the UserDeletingRow have been called from the delete button or from cell context menu delete or from row header context menu?

Regards,
Nadia

1 Answer, 1 is accepted

Sort by
0
Accepted
Ivan Petrov
Telerik team
answered on 10 Jul 2012, 01:39 PM
Hi Nadia,

Thank you for writing.

Currently, there is no direct way to determine what triggered the deletion from within the event. This thought is a good idea and I have logged it into our Public Issue Tracking System - PITS. You can track its status and add your vote/comment to it at the following link - PITS Feature. A possible work around is to use flags which are raised when the context menu is opened. Here is an example:
bool cellContextMenu = false;
bool rowHeaderContextMenu = false;
 
private void radGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
{
  if (e.ContextMenuProvider is GridDataCellElement)
  {
    this.cellContextMenu = true;
  }
  else if (e.ContextMenuProvider is GridRowHeaderCellElement)
  {
    this.rowHeaderContextMenu = true;
  }
}
 
private void radGridView1_UserDeletingRow(object sender, GridViewRowCancelEventArgs e)
{
  if (this.cellContextMenu)
  {
    this.cellContextMenu = false;
    MessageBox.Show("Cell context menu");
  }
  else if (this.rowHeaderContextMenu)
  {
    this.rowHeaderContextMenu = false;
    MessageBox.Show("Row header context menu");
  }
  else
  {
    MessageBox.Show("Pressed delete key");
  }
}
I have updated your Telerik points for the suggestion.

I hope this will be useful. Should you have further questions, I would be glad to help.
 
Kind regards,
Ivan Petrov
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Nadia Sangiovanni
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Share this question
or