Exemplo n.º 1
0
        public static DataView GetDataTable(int count)
        {
            DataTable dt = new DataTable("BusinessObjectsDataTable");
            PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(typeof(BusinessObject));

            foreach (PropertyDescriptor pd in pdc)
            {
                dt.Columns.Add(new DataColumn(pd.Name, pd.PropertyType));
            }
            BusinessObjectCollection list = BusinessObjectCollection.GetList(count);

            foreach (BusinessObject bo in list)
            {
                DataRow dr = dt.NewRow();
                foreach (PropertyDescriptor pd in pdc)
                {
                    dr[pd.Name] = pd.GetValue(bo);
                }
                dt.Rows.Add(dr);
            }
            return(dt.DefaultView);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads the List as DataSource for PivotGridControl
        /// </summary>
        private void LoadList()
        {
            this.pivotGrid1.ItemSource = null;
            this.pivotGrid1.ResetPivotData();
            this.pivotGrid1.ItemSource = BusinessObjectCollection.GetList(200);

            this.pivotGrid1.PivotRows.Add(new PivotItem()
            {
                FieldMappingName = "Fruit", FieldHeader = "Fruit", TotalHeader = "Total"
            });
            this.pivotGrid1.PivotRows.Add(new PivotItem()
            {
                FieldMappingName = "Color", FieldHeader = "Color", TotalHeader = "Total"
            });

            this.pivotGrid1.PivotColumns.Add(new PivotItem()
            {
                FieldMappingName = "Shape", FieldHeader = "Shape", TotalHeader = "Total"
            });
            this.pivotGrid1.PivotColumns.Add(new PivotItem()
            {
                FieldMappingName = "Even", FieldHeader = "Even", TotalHeader = "Total"
            });

            this.pivotGrid1.PivotCalculations.Add(new PivotComputationInfo()
            {
                FieldName = "Count", FieldHeader = "Count", SummaryType = SummaryType.DoubleTotalSum
            });
            this.pivotGrid1.PivotCalculations.Add(new PivotComputationInfo()
            {
                FieldName = "Section", FieldHeader = "Section", SummaryType = SummaryType.DoubleTotalSum
            });
            this.pivotGrid1.PivotCalculations.Add(new PivotComputationInfo()
            {
                FieldName = "Weight", FieldHeader = "Weight", SummaryType = SummaryType.DoubleTotalSum
            });
        }