WPF中Datagrid控件添加行号
标签:exce void ids sum row param nbsp code put
1 ///
2 /// 导入Excel文件按钮
3 ///
4 ///
5 ///
6 private void InputExcelFile_Click(object sender, RoutedEventArgs e)
7 {
8 //将数据绑定到datagird控件中
9 DataGridSheet.ItemsSource = readbynpoi.InputWorkbookFromExcel(GetExcelFilePath());
10 DataGridSheet.HeadersVisibility = DataGridHeadersVisibility.Row;
11 DataGridSheet.RowHeaderWidth = 30;
12 //LoadingRow事件
13 DataGridSheet.LoadingRow += DataGridSheet_LoadingRow;
14 }
15
16 private void DataGridSheet_LoadingRow(object sender, DataGridRowEventArgs e)
17 {
18 e.Row.Header = e.Row.GetIndex() + 1;//递增行号
19 }
WPF中Datagrid控件添加行号
标签:exce void ids sum row param nbsp code put
原文地址:https://www.cnblogs.com/sighful/p/10234698.html
评论