找回密码
 立即注册

QQ登录

只需一步,快速开始

roxland

新手上路

2

主题

4

帖子

36

积分

新手上路

积分
36
  • 32

    金币

  • 主题

  • 帖子

最新发帖
roxland
新手上路   /  发表于:2014-7-18 16:05  /   查看:8053  /  回复:12
当DataGrid 的AutoGenerateColumns="False" 时,如果增加合计行

12 个回复

倒序浏览
roxland
新手上路   /  发表于:2014-7-18 16:07:00
沙发
c1dg_AutoGeneratingColumn事件只有在自动表头才可以使用
回复 使用道具 举报
roxland
新手上路   /  发表于:2014-7-18 16:14:00
板凳
想使用DataGridSummaryRow
回复 使用道具 举报
Alice
社区贡献组   /  发表于:2014-7-18 18:40:00
地板
回复 3楼roxland的帖子

AutoGenerateColumns属性是控制列的。
增加合计行,XAMLcode参考如下:
  1.    <c1:C1DataGrid x:Name="grid" AutoGenerateColumns="False" CanUserAddRows="False" CanUserRemoveRows="False" ItemsSource="{Binding Players}" c1:C1NagScreen.Nag="True">
  2.     <c1:C1DataGrid.Columns>
  3.         <c1:DataGridTextColumn   GroupState="Ascending,0" SortState="Ascending,0" SortMemberPath="Name" FilterMemberPath="Name" Width="150" Header="Match" Binding="{Binding Match}">                    
  4.         </c1:DataGridTextColumn>
  5.         <c1:DataGridTextColumn Width="150" Header="Goals" Binding="{Binding Goals}">
  6.             <c1:DataGridAggregate.AggregateFunctions>
  7.                 <c1:DataGridAggregatesCollection>
  8.                     <c1:DataGridAggregateSum />
  9.                 </c1:DataGridAggregatesCollection>
  10.             </c1:DataGridAggregate.AggregateFunctions>
  11.         </c1:DataGridTextColumn>
  12.         <c1:DataGridTextColumn Width="50" Header="Minutes" Binding="{Binding Minutes}">
  13.             <c1:DataGridAggregate.AggregateFunctions>
  14.                 <c1:DataGridAggregatesCollection>
  15.                     <c1:DataGridAggregateSum />
  16.                 </c1:DataGridAggregatesCollection>
  17.             </c1:DataGridAggregate.AggregateFunctions>
  18.         </c1:DataGridTextColumn>
  19.     </c1:C1DataGrid.Columns>
  20.     <c1:C1DataGrid.BottomRows>
  21.         <c1:DataGridSummaryRow />
  22.         <c1:DataGridSummaryRow />
  23.     </c1:C1DataGrid.BottomRows>
  24. </c1:C1DataGrid>
复制代码

需要在LoadedCellPresenter 添加的代码:
  1. If e.Cell.Row.GetType() Is GetType(C1.Silverlight.DataGrid.Summaries.DataGridSummaryRow) Then
  2.     Dim _presenter = DirectCast(DirectCast(e.Cell.Presenter.Content, System.Windows.Controls.StackPanel).Children(0), System.Windows.Controls.ContentPresenter)
  3.     If (e.Cell.Row.Index = grid.Rows.Count – 2 AndAlso e.Cell.Column.Index = 2) Or (e.Cell.Row.Index = grid.Rows.Count – 1 AndAlso e.Cell.Column.Index = 1) Then
  4.         _presenter.Content = String.Empty
  5.     End If
  6. End If
复制代码
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
Ethan
葡萄城公司职员   /  发表于:2020-8-25 09:22:15
5#
@Alice,
使用以上方法加合计行,提示:没有ataGridAggregate.AggregateFunctions这个属性,如何解决?
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2020-8-25 10:50:53
6#
引用C1.WPF.DataGrid.Summaries,就可以了
回复 使用道具 举报
Ethan
葡萄城公司职员   /  发表于:2020-8-25 17:03:12
7#

@Richard.Ma, 在silverlight里可以这样用吗?
回复 使用道具 举报
Ethan
葡萄城公司职员   /  发表于:2020-8-25 17:04:16
8#
@Richard.Ma, 具体怎么引用,麻烦指导一下。
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2020-8-25 17:56:23
9#
sliverlight 和wpf中的xaml写法是一样的
因为我刚才也拖动了一个datagrid控件到wpf并添加了同样的合计行代码,xaml中也显示了这个错误,如果你遇到的就是这个错误的话,那就是缺少动态库引用导致的


没有的话就会有这个错误

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
Ethan
葡萄城公司职员   /  发表于:2020-8-25 18:08:38
10#
好的,我试一下,谢谢
回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部