如何在WPF中的数据网格上添加页脚行 [英] How to add footer row on datagrid in WPF

查看:75
本文介绍了如何在WPF中的数据网格上添加页脚行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在数据网格页脚上打印学生的总分数



我尝试了什么:



I want to Print the total marks of student on datagrid footer

What I have tried:

DataTable dt=new DataTable();
dt.Columns.Add("Subject",typeof(string));
dt.Columns.Add("Paper",typeof(string));
dt.Columns.Add("MaxMarks",typeof(string));
dt.Columns.Add("MinMarks",typeof(string));
dt.Columns.Add("ObtainMarks",typeof(string));
int totalMax = 0, totalMin = 0, totalObtain = 0;
DataGridShow.ItemsSource = ds.Tables[0].DefaultView ;
for (int i = 0; i < DataGridShow.Items.Count; i++)
{
    try
    {
        DataGridShow.SelectedIndex = i;
        DataRowView drv = (DataRowView)DataGridShow.SelectedItem;
        totalMax = totalMax + Convert.ToInt32(drv["MaxMarks"]);
        totalMin = totalMin + Convert.ToInt32(drv["MinMarks"]);

        totalObtain = totalObtain + Convert.ToInt32(drv["ObtainMarks"]);
    }
    catch(Exception x) { }
}

dt.Rows.Add("Total","",totalMax.ToString(),totalMin.ToString(),totalObtain.ToString());
DataGridShow.Items.Add(dt.Rows[0]);

推荐答案

您好,请参阅以下链接,

1. 博客de Thibaud :-):带有页脚和当前行指示符的WPFToolkit DataGrid [ ^ ]

2. c# - 如何在WPF数据网格中添加页脚行? - 堆栈溢出 [ ^ ]

3. WPF Extended DataGrid - Home [ ^ ]

4. WFF DataGrid:Frozen Row Sample | Vincent Sibal&#039;博客 [ ^ ]
Hi, refer the following links,
1. Le blog de Thibaud :-): WPFToolkit DataGrid with Footer and Current row indicator[^]
2. c# - How do I add a footer row in a WPF datagrid? - Stack Overflow[^]
3. WPF Extended DataGrid - Home[^]
4. WPF DataGrid: Frozen Row Sample | Vincent Sibal&#039;s Blog[^]


这篇关于如何在WPF中的数据网格上添加页脚行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆