We have inherited a project that uses RADGrid. It has both events for double and single clicking enabled.
But when DoubleClick is fired, so are Click and CellBeginEdit,...
I want to cancel Click, CellBeginEdit or others when DoubleClick is fired.
We have inherited a project that uses RADGrid. It has both events for double and single clicking enabled.
But when DoubleClick is fired, so are Click and CellBeginEdit,...
I want to cancel Click, CellBeginEdit or others when DoubleClick is fired.
I have an Inherited class Sheet from Telerik.WinControls.UI.RadGridView that I use as grid control in my project.
This resume what is needed to solve the problem:
public partial class Sheet : Telerik.WinControls.UI.RadGridView
{
//System Time to wait between Click and DoubleClick
private int _doubleClickTime = 500;
private bool _doubleClickRaised = false;
private bool _doubleClickCancelEdit = false;
public void FpSpread()
{
_doubleClickTime = System.Windows.Forms.SystemInformation.DoubleClickTime;
//...
}
protected override void OnMouseDoubleClick(MouseEventArgs e)
{
_doubleClickRaised = true;
_doubleClickCancelEdit = true;
base.OnMouseDoubleClick(e);
}
protected override void OnMouseClick(MouseEventArgs e)
{
//Doing what Telerik doesn't
//Wait system time needed for DoubleClick
System.Threading.Thread.Sleep(_doubleClickTime + 10);
Application.DoEvents();
if (_doubleClickRaised)
{
_doubleClickRaised = false;
return;
}
base.OnMouseClick(e);
}
//This only when editable cells...
protected override void OnCellBeginEdit(object sender, GridViewCellCancelEventArgs e)
{
if (_doubleClickCancelEdit)
{
_doubleClickCancelEdit = false;
e.Cancel = true;
}
base.OnCellBeginEdit(sender, e);
}
}
I hope this helps!!