المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : DataGridView line index cells



C# Programming
11-16-2009, 12:30 PM
Hi,

I'm trying to add line index cell to my DataGridView by iterating over the rows.
However, when the list has many rows (hundreds), this loop takes very long time due to CPU consuming.

The "heavy" part is converting the "int" to "String".

The code:
for (int iRowIter = 0; iRowIter < this.Rows.Count; iRowIter++)
this.Rows[iRowIter].Cells[0].Value = iRowIter + 1;

Any suggestions?
Thanks!