资源简介
DevExpress RichEditControl 动态插入表格及数据demo源代码,简单例子,希望对你们有帮助
代码片段和文件信息
using System;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using DevExpress.XtraRichEdit.Utils;
using DevExpress.XtraRichEdit.API.Native;
using DevExpress.Office.Utils;
namespace RichEditDisplayDataTable
{
public partial class Form1 : DevExpress.XtraBars.Ribbon.RibbonForm
{
public Form1()
{
InitializeComponent();
}
private void AppendDataTable(Document document DataTable dataTable)
{
int dataTableRows = dataTable.Rows.Count;
int dataTableColumns = dataTable.Columns.Count;
List columnsToDisplay = new List();
for (int i = 0; i < dataTableColumns; i++)
{
string name = dataTable.Columns[i].ColumnName;
// Skip PrimaryKey columns
if (!name.ToUpper().EndsWith(“ID“))
columnsToDisplay.Add(name);
}
document.BeginUpdate();
Table table = document.Tables.Create(document.Range.End dataTableRows + 1 columnsToDisplay.Count AutoFitBehaviorType.AutoFitToWindow);
SetTablestyle(table);
//段落参数设置
ParagraphProperties pp = document.BeginUpdateParagraphs(table.FirstRow.Range);
pp.Alignment = ParagraphAlignment.Center;
document.EndUpdateParagraphs(pp);
//字体设置
CharacterProperties cp = document.BeginUpdateCharacters(table.FirstRow.Range);
cp.FontName = “Courier New“;
cp.ForeColor = Color.White;
document.EndUpdateCharacters(cp);
DrawHeader(document table columnsToDisplay);
// 填充表格内容
table.BeginUpdate();//开启,以提高绘制效率
table.ForEachCell(delegate (TableCell cell int rowIndex int cellIndex)
{
if (rowIndex > 0)
{
document.InsertText(cell.Range.Start dataTable.Rows[rowIndex - 1][columnsToDisplay[cellIndex]].ToString());
}
});
table.EndUpdate();
document.EndUpdate();
}
///
/// 绘制表头
///
///
///
///
void DrawHeader(Document document Table table List columnsToDisplay)
{
for (int i = 0; i < table.FirstRow.Cells.Count; i++)
{
table.FirstRow.Cells[i].BackgroundColor = Color.DarkBlue;
table.FirstRow.Cells[i].VerticalAlignment = TableCellVerticalAlignment.Center;
}
// 填充表头
for (int i = 0; i < columnsToDisplay.Count; i++)
{
document.InsertText(table[0 i].Range.Start columnsToDisplay[i]);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-02-10 15:43 RichEditDisplayDataTableDemo\
目录 0 2017-02-10 15:43 RichEditDisplayDataTableDemo\.vs\
目录 0 2017-02-10 14:29 RichEditDisplayDataTableDemo\.vs\RichEditDisplayDataTableDemo\
目录 0 2017-02-10 14:55 RichEditDisplayDataTableDemo\.vs\RichEditDisplayDataTableDemo\v14\
文件 38400 2017-02-10 15:44 RichEditDisplayDataTableDemo\.vs\RichEditDisplayDataTableDemo\v14\.suo
目录 0 2017-02-10 14:29 RichEditDisplayDataTableDemo\.vs\Supercharger\
目录 0 2017-02-10 15:44 RichEditDisplayDataTableDemo\.vs\Supercharger\RichEditDisplayDataTable\
文件 7196 2017-02-10 15:44 RichEditDisplayDataTableDemo\.vs\Supercharger\RichEditDisplayDataTable\codemap.dat
文件 8605 2017-02-10 15:44 RichEditDisplayDataTableDemo\.vs\Supercharger\RichEditDisplayDataTable\global_history.dat
文件 228 2017-02-10 15:44 RichEditDisplayDataTableDemo\.vs\Supercharger\RichEditDisplayDataTable\workbench.dat
文件 11921 2017-02-10 15:41 RichEditDisplayDataTableDemo\Form1.Designer.cs
文件 4538 2017-02-10 15:41 RichEditDisplayDataTableDemo\Form1.cs
文件 6232 2017-02-10 15:41 RichEditDisplayDataTableDemo\Form1.resx
文件 1173 2017-02-10 15:29 RichEditDisplayDataTableDemo\ProductsTable.cs
文件 479 2017-02-10 15:37 RichEditDisplayDataTableDemo\Program.cs
目录 0 2017-02-10 15:41 RichEditDisplayDataTableDemo\Properties\
文件 1298 2017-02-10 14:29 RichEditDisplayDataTableDemo\Properties\AssemblyInfo.cs
文件 2874 2017-02-10 14:29 RichEditDisplayDataTableDemo\Properties\Resources.Designer.cs
文件 5612 2017-02-10 14:28 RichEditDisplayDataTableDemo\Properties\Resources.resx
文件 1105 2017-02-10 14:29 RichEditDisplayDataTableDemo\Properties\Settings.Designer.cs
文件 249 2017-02-10 14:28 RichEditDisplayDataTableDemo\Properties\Settings.settings
文件 401 2017-02-10 15:41 RichEditDisplayDataTableDemo\Properties\licenses.licx
文件 8314 2017-02-10 15:40 RichEditDisplayDataTableDemo\RichEditDisplayDataTable.csproj
文件 6272 2017-02-10 14:28 RichEditDisplayDataTableDemo\RichEditDisplayDataTable.csproj.bak
文件 453 2017-02-10 15:36 RichEditDisplayDataTableDemo\RichEditDisplayDataTable.csproj.user
文件 935 2017-02-10 14:29 RichEditDisplayDataTableDemo\RichEditDisplayDataTableDemo.sln
文件 144 2017-02-10 15:36 RichEditDisplayDataTableDemo\app.config
目录 0 2017-02-10 15:40 RichEditDisplayDataTableDemo\bin\
目录 0 2017-02-10 15:40 RichEditDisplayDataTableDemo\bin\Debug\
文件 6013736 2016-12-18 09:19 RichEditDisplayDataTableDemo\bin\Debug\DevExpress.Data.v16.2.dll
文件 1269161 2016-12-18 09:19 RichEditDisplayDataTableDemo\bin\Debug\DevExpress.Data.v16.2.xm
............此处省略113个文件信息
- 上一篇:知识图谱与认知智能
- 下一篇:计算机网络 谢希仁版高清PDF
相关资源
- Nise - Control Systems Engineering 6th (c201
- Statistics Data Analysis and Decision Modeling
-
Databa
se Management Systems3rd edition) - sliding mode control in engineering178154
- Matrix Computation 4th Edition
- Introduction to Operation Researchs 10th Editi
- jsf+richfaces+hiberante项目源码(个人日志
- R in a Nutshell 2nd Edition
- Laser Fundamentals(Second Edition)William
- Optimal Control Linear Quadratic Methods
- Industrial Motion Control MOTOR SELECTION DRIV
- Digital Image Processing 4th Edition
- Mastering ROS for Robotics Programming - Secon
- Introduction to Mathematical Statistics (8th
- BCGControlBar 英文说明文档 28版本
- Vehicle Dynamics and Control
- Feedback Control of Dynamic Systems 6th editio
- software Engineering by Ian Sommerville 9th Ed
- Hackers - Heroes of the Computer Revolution(
- Git Mastering Version Control 无水印原版p
- Software Engineering Theory and Practice (4t
- CCIE Routing and Switching v5.0 Official Cert
- Communication Systems 4Th Edition Simon Haykin
- Sliding Modes in Control and Optimization.pdf
- 飞行稳定性和自动控制
- arcgis_editor_for_osm10.2
- Algorithms 4th Edition算法第四版英文原版
- CANdb++使用指导
- PMP Exam Prep 9th Edition pdf
- operating system concepts 7th edition中文
评论
共有 条评论