提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
原创|其它|编辑:郝浩|2012-10-17 14:08:50.000|阅读 3873 次
概述:本文通过一个具体的事例,为大家阐述如何绑定DevExpress的 PivotGridControl 到数据库。
# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>
本文通过一个具体的事例,为大家阐述如何绑定DevExpress的 PivotGridControl 到数据库。
事例数据库如下:
代码如下:
C#
using DevExpress.LookAndFeel; using DevExpress.XtraPivotGrid; using System.Data.OleDb; // Create a connection object. OleDbConnection connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\DB\\NWIND.MDB"); // Create a data adapter. OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM SalesPerson", connection); // Create and fill a dataset. DataSet sourceDataSet = new DataSet(); adapter.Fill(sourceDataSet, "SalesPerson"); // Assign the data source to the XtraPivotGrid control. pivotGridControl1.DataSource = sourceDataSet.Tables["SalesPerson"]; // Create a row PivotGridControl field bound to the Country datasource field. PivotGridField fieldCountry = new PivotGridField("Country", PivotArea.RowArea); // Create a row PivotGridControl field bound to the Sales Person datasource field. PivotGridField fieldCustomer = new PivotGridField("Sales Person", PivotArea.RowArea); fieldCustomer.Caption = "Customer"; // Create a column PivotGridControl field bound to the OrderDate datasource field. PivotGridField fieldYear = new PivotGridField("OrderDate", PivotArea.ColumnArea); fieldYear.Caption = "Year"; // Group field values by years. fieldYear.GroupInterval = PivotGroupInterval.DateYear; // Create a column PivotGridControl field bound to the CategoryName datasource field. PivotGridField fieldCategoryName = new PivotGridField("CategoryName", PivotArea.ColumnArea); fieldCategoryName.Caption = "Product Category"; // Create a filter PivotGridControl field bound to the ProductName datasource field. PivotGridField fieldProductName = new PivotGridField("ProductName", PivotArea.FilterArea); fieldProductName.Caption = "Product Name"; // Create a data PivotGridControl field bound to the 'Extended Price' datasource field. PivotGridField fieldExtendedPrice = new PivotGridField("Extended Price", PivotArea.DataArea); fieldExtendedPrice.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric; // Specify the formatting setting to format summary values as integer currency amount. fieldExtendedPrice.CellFormat.FormatString = "c0"; // Add the fields to the control's field collection. pivotGridControl1.Fields.AddRange(new PivotGridField[] {fieldCountry, fieldCustomer, fieldCategoryName, fieldProductName, fieldYear, fieldExtendedPrice}); // Arrange the row fields within the Row Header Area. fieldCountry.AreaIndex = 0; fieldCustomer.AreaIndex = 1; // Arrange the column fields within the Column Header Area. fieldCategoryName.AreaIndex = 0; fieldYear.AreaIndex = 1; // Customize the control's look-and-feel via the Default LookAndFeel object. UserLookAndFeel.Default.UseWindowsXPTheme = false; UserLookAndFeel.Default.Style = LookAndFeelStyle.Skin; UserLookAndFeel.Default.SkinName = "Money Twins";
VB
Imports DevExpress.LookAndFeel Imports DevExpress.XtraPivotGrid Imports System.Data.OleDb ' Create a connection object. Dim connection As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\DB\\NWIND.MDB") ' Create a data adapter. Dim adapter As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM SalesPerson", connection) ' Create and fill a dataset. Dim sourceDataSet As DataSet = New DataSet adapter.Fill(sourceDataSet, "SalesPerson") ' Assign the data source to the XtraPivotGrid control. PivotGridControl1.DataSource = sourceDataSet.Tables("SalesPerson") ' Create a row PivotGridControl field bound to the Country datasource field. Dim fieldCountry As PivotGridField = New PivotGridField("Country", PivotArea.RowArea) ' Create a row PivotGridControl field bound to the Sales Person datasource field. Dim fieldCustomer As PivotGridField = New PivotGridField("Sales Person", PivotArea.RowArea) fieldCustomer.Caption = "Customer" ' Create a column PivotGridControl field bound to the OrderDate datasource field. Dim fieldYear As PivotGridField = New PivotGridField("OrderDate", PivotArea.ColumnArea) fieldYear.Caption = "Year" ' Group field values by years. fieldYear.GroupInterval = PivotGroupInterval.DateYear ' Create a column PivotGridControl field bound to the CategoryName datasource field. Dim fieldCategoryName As PivotGridField = New PivotGridField("CategoryName", PivotArea.ColumnArea) fieldCategoryName.Caption = "Product Category" ' Create a filter PivotGridControl field bound to the ProductName datasource field. Dim fieldProductName As PivotGridField = New PivotGridField("ProductName", PivotArea.FilterArea) fieldProductName.Caption = "Product Name" ' Create a data PivotGridControl field bound to the 'Extended Price' datasource field. Dim fieldExtendedPrice As PivotGridField = New PivotGridField("Extended Price", PivotArea.DataArea) fieldExtendedPrice.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric ' Specify the formatting setting to format summary values as integer currency amount. fieldExtendedPrice.CellFormat.FormatString = "c0" ' Add the fields to the control's field collection. PivotGridControl1.Fields.AddRange(New PivotGridField() {fieldCountry, fieldCustomer, _ fieldCategoryName, fieldProductName, fieldYear, fieldExtendedPrice}) ' Arrange the row fields within the Row Header Area. fieldCountry.AreaIndex = 0 fieldCustomer.AreaIndex = 1 ' Arrange the column fields within the Column Header Area. fieldCategoryName.AreaIndex = 0 fieldYear.AreaIndex = 1 ' Customize the control's look-and-feel via the Default LookAndFeel object. UserLookAndFeel.Default.UseWindowsXPTheme = False UserLookAndFeel.Default.Style = LookAndFeelStyle.Skin UserLookAndFeel.Default.SkinName = "Money Twins"
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@cahobeh.cn
文章转载自:慧都控件网面对“数字中国”建设和中国制造2025战略实施的机遇期,中车信息公司紧跟时代的步伐,以“集约化、专业化、标准化、精益化、一体化、平台化”为工作目标,大力推进信息服务、工业软件等核心产品及业务的发展。在慧都3D解决方案的实施下,清软英泰建成了多模型来源的综合轻量化显示平台、实现文件不失真的百倍压缩比、针对模型中的大模型文件,在展示平台上进行流畅展示,提升工作效率,优化了使用体验。
本站的模型资源均免费下载,登录后即可下载。模型仅供学习交流,勿做商业用途。
本站的模型资源均免费下载,登录后即可下载。模型仅供学习交流,勿做商业用途。
本站的模型资源均免费下载,登录后即可下载。模型仅供学习交流,勿做商业用途。
完全支持用户自定义,完全支持与DevExpress图表控件本地集成,终端用户通过简单的拖动和点击就可创建几乎无限数组的报表
ASPxPivotGrid Suite能够高效的对数据进行切分,从而为客户提供一个非常直观的终端用户体验
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@cahobeh.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢