2017-04-27 99 views

回答

0

我有一個從我的項目中用作網格控件的Telerik.WinControls.UI.RadGridView的繼承類表。

這種簡歷去解決問題所需要的:

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); 
    } 

} 

我希望這有助於!