首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C# winform 状态栏控件System.ArgumentOutOfRangeException: 索引超出范围,该如何处理

2013-10-21 
C# winform 状态栏控件System.ArgumentOutOfRangeException: 索引超出范围状态栏控件是显示当前读取进度的

C# winform 状态栏控件System.ArgumentOutOfRangeException: 索引超出范围
状态栏控件是显示当前读取进度的,运行一段时间后有时候就会出现这个错误,并不是每次都会出现

然后控件就成一个大红X,运行的时候只是改了控件的Text值,没做其他的,这是什么原因?


************** 异常文本 **************
System.ArgumentOutOfRangeException: 索引超出范围。必须为非负值并小于集合大小。
参数名: index
   在 System.Collections.ArrayList.get_Item(Int32 index)
   在 System.Windows.Forms.ToolStripItemCollection.get_Item(Int32 index)
   在 System.Windows.Forms.ToolStrip.OnPaint(PaintEventArgs e)
   在 System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
   在 System.Windows.Forms.Control.WmPaint(Message& m)
   在 System.Windows.Forms.Control.WndProc(Message& m)
   在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   在 System.Windows.Forms.ToolStrip.WndProc(Message& m)
   在 System.Windows.Forms.StatusStrip.WndProc(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

[解决办法]
跟踪代码吧,你肯定是访问列表或数组越界了
ystem.Collections.ArrayList.get_Item(Int32 index),这里访问了不存在的下标,出错时,应该会定位到你的错误行的,看看当时的下标值
[解决办法]
很明显越界了。。。

热点排行