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

Selection Changed Event is fired multiple time

1 Answer 216 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vincent
Top achievements
Rank 1
Vincent asked on 15 Nov 2018, 07:15 PM

Hi ! 

Every time that I update the query of my gridview, the SelectionChanged event is fired like 10 time in a row.

On this event, I have a procedure that takes some time so the action is very slow.

Is there a way to prevent that ? 

Thank you!

 

 

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 16 Nov 2018, 01:13 PM
Hello, Vincent, 

When the selection in RaGridView is changed, it is expected that the SelectionChanged is fired. If you want to skip the execution of a specific operation that is performed in the SelectionChanged event handler, you can suspend the event and resume it later. Thus, while you are refreshing the grid, the SelectionChanged event won't be fired. You can find below a sample code snippet:

private void radButton1_Click(object sender, EventArgs e)
{
    Telerik.WinControls.UI.EventDispatcher dispatcher = this.radGridView1.MasterTemplate.EventDispatcher;
    dispatcher.SuspendEvent(EventDispatcher.SelectionChanging);
    dispatcher.SuspendEvent(EventDispatcher.SelectionChanged);
}
 
private void radButton2_Click(object sender, EventArgs e)
{
    EventDispatcher dispatcher = this.radGridView1.MasterTemplate.EventDispatcher;
    dispatcher.ResumeEvent(EventDispatcher.SelectionChanging);
    dispatcher.ResumeEvent(EventDispatcher.SelectionChanged);
}

I hope this information helps.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Vincent
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or