برنامه نویسی
برنامه حسابداری نوشتم کد قسمت محاسبات یعنی جمع ستون قیمت به صورت زیر است :

DataGridViewCell cel = new DataGridViewButtonCell();

DataGridViewRow GridRow = new DataGridViewRow();

long num = 0;

for (int j = 0; j < n - 1; j++)

{

GridRow = dataGridView1.Rows[j];

cel = GridRow.Cells[4];

num += System.Convert.ToInt64(cel.Value.ToString(), 10);

}

label26.Text = num.ToString();

اما باپیغام خطای زیر مواجه می شوم

An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll

Additional information: Index was out of range. Must be non-negative and less than the size of the collection.

جواب :

یکی از اشکالاتی که خودم نیز باهاش مواجه شدم همین بود که پس از پر کردن فیلد  اشکال بر طرف شد شما نیز تست کنید شاید اشکال همین باشد یعنی فیلد حتما مقدار داشته باشد

+ نوشته شده در  پنجشنبه یازدهم فروردین ۱۳۹۰ساعت 23:11  توسط ابراری |