我遇到了一個令人沮喪的錯誤,我確定它很簡單,但我無法弄清楚是什麼。設置datagridview單元格值的索引錯誤
這裏是我的功能:。
public void setDistanceCellValue(int value, int row, int column)
{
try
{
Console.WriteLine("Row: " + row + " Column: " + column + " Value: " + value);
logGrid.Rows[row].Cells[column].Value = value.ToString();
}
catch (Exception ex)
{
MessageBox.Show(string.Format("An error occurred: {0}" + "\r\n" + "\r\n" + "Row: " + row + " Column: " + column + " Value: " + value, ex.Message));
}
}
凡logGrid
值設定線就是與「索引超出範圍示數出必須爲非負數且小於集合的大小參數名稱:索引「。
我一直在檢查和檢查,我的網格有6行8列,並且該函數被稱爲第2行第3列(因此所有的調試代碼)。對於我的生活,我無法弄清楚爲什麼它說我正在使用負指數或e.rowIndex
或7對於e.columnIndex
大於5的指數。
幫我,如果你可以。
你能告訴我們這個函數被調用的循環嗎? – roymustang86 2012-02-26 21:37:12