问题描述
我有一个在datagridview中设置行号的方法,如下所示:
i have a method for set row number in datagridview like below :
public static void setRowNumber(DataGridView dgv)
{
for (int i = 0; i < dgv.Rows.Count; i++)
{
dgv.Rows[i].HeaderCell.Value = (i + 1).ToString();
}
}
当我用以下两种方式调用此方法时,datagrid填充非常慢(大多数时间超过10秒):
1-在表单加载事件中,调用fillgrid,并在fillgrid方法的最后一行调用setRowNumber
2在DataGridView事件的CellFormating中
现在,我的问题是
1-哪里是调用此方法设置行的最佳位置datagridview中的数字
2-是setRowNumber有足够的性能
谢谢大家
when i call this method in two below ways , datagrid fill very slow (Most of the time more than 10 seconds) :
1- in form load event , call fillgrid , and in last line of fillgrid method call setRowNumber
2- in CellFormating of DataGridView event
now, my questions are
1- where is best place to call this method to set row number in datagridview
2- is setRowNumber has enough performance
Thanks Guys
推荐答案
这篇关于c#中datagridview中设置行号的最佳事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!