我在表单中使用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上没有例外,表单成功关闭。 是什么原因导致异常以及如何修复它? 在此先感谢。
答案 0 :(得分:0)
覆盖解决了异常:
public class MydbiSchedule : Dbi.WinControl.Schedule.dbiSchedule
{
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.KeyCode != Keys.Escape)
base.OnKeyDown(e);
}
}