在我正在構建的測試應用程序中,當試圖繪製圖表時遇到了此錯誤。我試圖繪製甘特圖時崩潰我的測試應用中的一些僞隨機生成的數據...TeeChart甘特圖「System.ArgumentOutOfRangeException未處理」錯誤
System.ArgumentOutOfRangeException了未處理的HResult = -2146233086 消息=索引超出範圍。必須是非負數,並且小於集合的大小 。參數名稱:索引= PARAMNAME指數 源= mscorlib程序堆棧跟蹤:在 System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument 說法,ExceptionResource資源)處 Steema.TeeChart.Styles.Gantt Steema.TeeChart.Styles.Gantt.CopyNextTasks() Steema.TeeChart.Chart.DrawAllSeries(Graphics3D g,Int32 First,Int32 Last, Int32 Inc)。克)在 Steema.TeeChart.Chart.InternalDraw(圖形克,布爾noTools)處 Steema.T Steema.TeeChart.Chart.InternalDraw(圖形克)在 Steema.TeeChart.TChart.Draw(圖形克) eeChart.TChart.OnPaint(PaintEventArgs的PE)在 System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs的E, Int16的層)在System.Windows.Forms.Control.WmPaint(消息& m)上 System.Windows.Forms的.Control.WndProc(消息& m)上 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(消息&米) 在System.Windows.Forms.Control.ControlNativeWindow.WndProc(消息& m)上System.Windows .Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)InnerException:
它似乎在TeeChart甘特圖繪製邏輯中下降了。
我的項目是在這裏:https://www.dropbox.com/sh/haqspd4ux41n2uf/AADkj2H5GLd09oJTW-HrAVr3a?dl=0
如果有人想複製它。
此測試代碼確實用於在舊版本的TeeChart 2.0.2670.26520版本中正確執行。
圍繞它得到任何意見或建議,將不勝感激。
感謝您的答覆納西斯。我想我明白我要去哪裏錯了。每個系列的最後一項任務必須以-1結尾。不過,我不確定你的建議是否完全正確。我想: 'crewSeries.NextTasks [crewSeries.Count - 1] =(crewSeries.Count == crewDataView.Count - 1)? crewSeries.Count:-1;' 應該是: 'crewSeries.NextTasks [crewSeries.Count - 1] =(crewSeries.Count <= crewDataView.Count - 1)? crewSeries.Count:-1;' –
是的,你說得對。我更正了我的答案:crewSeries.NextTasks [crewSeries.Count - 1] =(crewSeries.Count == crewDataView.Count - 1)? -1:crewSeries.Count ;.重點不在於系列中的最後一項任務應指向-1,而應指向0到crewSeries.Count - 1範圍內的現有索引。 –