DbiSchedule控件对Escape键点击异常被抛出无法访问被处置对象

时间:2016-09-07 08:05:22

标签: c# .net winforms dbi

我在表单中使用DbiSchedule控件,在转义键上单击我关闭表单。抛出错误的ObjectDisposed异常和stackTrace如下:

System.Windows.Forms.dll!System.Windows.Forms.Control.CreateHandle()    
    System.Windows.Forms.dll!System.Windows.Forms.Control.Handle.get()  
    System.Windows.Forms.dll!System.Windows.Forms.Control.CreateGraphicsInternal()  
    System.Windows.Forms.dll!System.Windows.Forms.Control.CreateGraphics()  Unknown
    Dbi4.dll!Dbi.WinControl.DbiListControl.OnKeyDown(System.Windows.Forms.KeyEventArgs e)   
    System.Windows.Forms.dll!System.Windows.Forms.Control.ProcessKeyEventArgs(ref System.Windows.Forms.Message m)   
    System.Windows.Forms.dll!System.Windows.Forms.Control.ProcessKeyMessage(ref System.Windows.Forms.Message m) 
    System.Windows.Forms.dll!System.Windows.Forms.Control.WmKeyChar(ref System.Windows.Forms.Message m) 
    System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m)   
    System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) 
    System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m)   
    System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam)

ALT + F4上没有例外,表单成功关闭。 是什么原因导致异常以及如何修复它? 在此先感谢。

1 个答案:

答案 0 :(得分:0)

覆盖解决了异常:

public class MydbiSchedule : Dbi.WinControl.Schedule.dbiSchedule
    {      

        protected override void OnKeyDown(KeyEventArgs e)
        {
            if (e.KeyCode != Keys.Escape)
                base.OnKeyDown(e);
        }

    }