How to prevent double click on paging control from firing off mouse double click event?

1 Answer 67 Views
GridView
Kevin
Top achievements
Rank 2
Iron
Iron
Iron
Kevin asked on 07 Dec 2023, 01:18 PM

I have a radgridview grid with paging.  I have a mouse double click event:


private void RgvSyncUp_MouseDoubleClick(object? sender, MouseEventArgs e)
{
	var rgv = (RadGridView)sender;
	var myRow = rgv.CurrentRow;
	var dlg = new DlgPendingSync(myRow);
	dlg.ShowDialog();
}

 

The problem I am having is this, that if the user double clicks a paging control it fires off the mouse double click event and the dialog mentioned in the code gets shown. 

Is there a way to trap or prevent this or prevent the double click on the paging control from firing off my dialog?

 

Thank you,

Kevin

 

 

 

1 Answer, 1 is accepted

Sort by
1
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 07 Dec 2023, 02:29 PM

Hi Kevin,

Thank you for sharing the code snippet.

The paging panel is part of the RadGridView control. That is why the MouseDoubleClick event is fired. What you can do is to check the element under the click mouse location. If the element is part of the paging panel, call return.

private void RadGridView1_MouseDoubleClick(object sender, MouseEventArgs e)
{
    var elementUnderMouse = this.radGridView1.GridViewElement.ElementTree.GetElementAtPoint(e.Location);
    if (elementUnderMouse is RadCommandBarBaseItem || elementUnderMouse is RadCommandBarElement || elementUnderMouse is CommandBarStripElement)
    {
        return;
    }   
    //execute your custom logic
}

Give this approach a try and let me know if it works for you.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Kevin
Top achievements
Rank 2
Iron
Iron
Iron
commented on 07 Dec 2023, 02:54 PM

That worked!  Also gives me something to study.  Thank you!
Tags
GridView
Asked by
Kevin
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or