在一个DataGridView的行标题显示行数 [英] Show row number in row header of a DataGridView
本文介绍了在一个DataGridView的行标题显示行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
时它可以显示在的DataGridView
的行标题行号?
Is it possible to show row number in the row header of a DataGridView
?
我想这个code,但它不工作:
I'm trying with this code, but it doesn't work:
private void setRowNumber(DataGridView dgv)
{
foreach (DataGridViewRow row in dgv.Rows)
{
row.HeaderCell.Value = row.Index + 1;
}
}
我是否需要设置一些的DataGridView
属性?
推荐答案
看来,它并没有把它变成一个字符串。 尝试
It seems that it doesn't turn it into a string. Try
row.HeaderCell.Value = String.Format("{0}", row.Index + 1);
这篇关于在一个DataGridView的行标题显示行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文