灌篮少年 发表于 2024-11-17 11:43:22

wpf的C1FlexGrid可见表格归并盘算操作

盘算动态加载行后的部分字段的盘算求和操作

表格上添加变乱触发ItemsSourceChanged属性,触发变乱
<c1:C1FlexGrid Name="CfgSaleOrderReviewItem" Style="{StaticResource Green}" ItemsSource="{Binding SaleOrderList,Mode=TwoWay}" SelectedItem="{Binding CurrentSaleOrderItem,Mode=TwoWay}" 
                        LoadedRows="FlexGrid_LoadedSaleOrderRows_RowIndex" PreviewKeyDown="c1FlexGrid_PreviewKeyDown"  IsReadOnly="False"
                        ItemsSourceChanged="DetailGrid_ItemsSourceChanged">

编写变乱
    /// <summary>
        /// 列表1合计
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DetailGrid_ItemsSourceChanged(object sender, EventArgs e)
        {
            var vm = DataContext as PlateReplaceApplyFormVM;
            if (vm == null) return;
            CfgSaleOrderReviewItem.ColumnFooterRows.Clear();

            var gr = new GroupRow()
            {
                FontWeight = FontWeights.Bold
            };
            if (vm.SaleOrderList != null && vm.SaleOrderList.Count > 0) {
                CfgSaleOrderReviewItem.ColumnFooters.Rows.Add(gr);
                gr["ManagerName"] = "合计";
                gr["ProductQuantity"] = vm.SaleOrderList == null ? 0 : vm.SaleOrderList.Sum(p => Convert.ToInt32(p.ProductQuantity));
                gr["ProductTotalArea"] = vm.SaleOrderList == null ? 0 : vm.SaleOrderList.Sum(p => Convert.ToDouble(p.ProductTotalArea));
            }
        }

效果
https://i-blog.csdnimg.cn/direct/d71b111d0f74409b94bf4d0ae9d26463.png


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: wpf的C1FlexGrid可见表格归并盘算操作