【转载】wpf DataGrid自动显示行号

来源:http://www.cnblogs.com/Laro/archive/2011/04/04/2005490.html

将datagrid加入序号的方法,在事件中加入如下代码:

dataGrid.LoadingRow +=new EventHandler<DataGridRowEventArgs>(dataGrid_LoadingRow);

关键代码

//添加行号
publicvoid dataGrid_LoadingRow(object sender, DataGridRowEventArgs e)
{
e.Row.Header = e.Row.GetIndex() +1;
}

  

posted @ 2013-05-13 17:42  信息科技张老师  阅读(488)  评论(0编辑  收藏  举报