我已经自定义了cellpainting事件处理程序,并尝试向datagridview添加300行,并在滚动垂直滚动条时观察到以下运行时异常。
System.InvalidOperationException: Operation is not valid due to the current state of the object.
at System.Windows.Forms.DataGridView.ScrollRowsByHeight(Int32 height)
at System.Windows.Forms.DataGridView.set_VerticalOffset(Int32 value)
at System.Windows.Forms.DataGridView.DataGridViewVScrolled(Object sender, ScrollEventArgs se)
at System.Windows.Forms.ScrollBar.OnScroll(ScrollEventArgs se)
at System.Windows.Forms.ScrollBar.DoScroll(ScrollEventType type)
at System.Windows.Forms.ScrollBar.WmReflectScroll(Message& m)
at System.Windows.Forms.ScrollBar.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
此处提供代码:http://pastebin.com/bN5v5PbS