WinForms Controls v25.1
AI 驱动的语义搜索
我们的 WinForms 数据网格、GridLookUpEdit 和 SearchLookUpEdit 控件具有增强的搜索体验,使用户能够更快/更准确地在大型数据集中查找相关数据。与基于关键字的标准搜索不同,语义搜索利用自然语言处理 (NLP) 来分析超出精确关键字匹配的搜索查询。
语义搜索使用嵌入生成器将文本转换为数字向量表示形式。向量嵌入存储在矢量存储(例如,数据库、内存中集合或将向量值存储在文件中的自定义实现)。当用户输入搜索查询时,搜索引擎会计算查询向量和存储的数据向量之间的相似性分数,以返回最相关的结果。
启用 AI 驱动的语义搜索后,搜索框中会显示一个下拉按钮。弹出菜单允许用户指定搜索模式:
- 标准- 传统的基于关键字的搜索。
- 语义- 基于向量的语义搜索,用于查找概念上相似的项目。
- 混合- 标准搜索和语义搜索的组合。
安装 DevExpress WinForms 产品库.
语义搜索可以在两种模式下运行:
- Filter Mode- 仅显示匹配的记录。
- 搜索模式- 突出显示相关数据行,以便更直观地发现数据。
要在 WinForms 数据网格或数据查找控件中启用语义搜索,您必须注册嵌入生成器,提供向量存储/数据库,将我们的新连接到网格或查找控件,并配置行为设置(例如,嵌入生成器、向量存储、向量存储中的记录类型、数据源键字段、搜索模式、 搜索准确性、最大结果数等)。SemanticSearchBehavior
文档
模板套件
#WinForms 应用程序生成器
从头开始构建模块化/多视图 WinForms 应用程序需要大量的设置工作 — 从选择最佳导航模型到集成适当的 UI 组件。我们新的 Application Builder 模板可自动执行这些基础步骤,使开发人员能够专注于业务逻辑和用户体验,而不是样板代码。
DevExpress WinForms Application Builder 使用一个简单的 2 步交互式向导:
步骤 1:选择 Navigation 模型
为您的项目指定所需的导航结构:
- Accordion
- Tabbed Accordion
- Compact List
- Tabbed Window
第 2 步:选择 DevExpress Controls
根据项目要求选择预配置的 DevExpress UI 控件。
根据您的选择,模板会自动生成一个应用程序,其中包含:
- 完全配置的导航系统。
- 每个选定 UI 控件的单独视图。
#新的 'Middle-Tier Security Application' 项目模板
使用此项目模板,您可以快速构建高性能 WinForms 应用程序并将其连接到 ASP.NET Core 中间层服务器。此模板基于功能齐全的例应用程序,专为对由 .NET 8+ 提供支持的安全/可扩展解决方案感兴趣的用户而设计。
如您所料,该模板旨在最大限度地降低设置复杂性。借助它,您可以:
- 使用 EF Core 为应用程序业务实体和安全策略构建数据模型。
- 使用 DevExpress ASP.NET Core Middle-Tier Security Server 将 Windows Forms .NET 8 客户端应用程序连接到后端。
- 定义访问权限并激活 .NET 8 WinForms 应用程序的身份验证/授权。
- 根据用户特定的访问权限自定义 UI/UX。
- 创建登录表单以对用户进行身份验证。
- 创建编辑表单以修改和发布数据 (CRUD)。
文档 示例 (GitHub)
#新的 DevExpress 项目模板
模板工具包 v25.1 允许您将以下 DevExpress 支持的 UI 元素/控件添加到您的 .NET 8+ WinForms 项目中:
DevExpress 表单:
- Foem (XtraForm)
- DirectX Form
- Fluent Design Form
- Modular Form
- Ribbon Form
- Splash Screen
- Tabbed MDI Form
- Toolbar Form
- Wait Form
- Wizard Form
DevExpress 用户控件:
- User Control
- Modular User Control
其他模板:
- Dashboard
- Custom Data Editor
- Custom Data Grid
可及性
#基于助记词的子菜单导航
在 v25.1 中,我们增强了基于工具栏的传统用户界面的键盘辅助功能。用户可以在具有相同助记词的子菜单项之间循环(用 in captions 表示)。当子菜单中的多个项目具有相同的助记词时,重复的按键会按顺序浏览它们。该功能会自动启用,不需要其他配置。&
- C#
barItemSaveAs.Caption = "Save &As";
barItemSaveAll.Caption = "Save &All";
#Accordion 快捷方式
折叠面板项现在支持键盘快捷键。使用快捷键属性指定预定义或自定义键盘快捷键。此增强功能提高了辅助功能,特别是对于具有复杂导航结构的应用程序。
- C#
accordionControlElement1.ShortcutKey = new DevExpress.XtraBars.BarShortcut(Keys.J);
#BarItem - 支持 AutomationId
该属性是区分自动测试和辅助功能 (a11y) 工具中的 UI 元素的唯一标识符,现在可用于对象。此属性会自动设置为条形项目的 。AutomationId
BarItem
Name
JSON 序列化
DevExpress WinForms UI 控件现在支持基于 JSON 的布局序列化 - XML 的替代方案,用于简化与现代 Web 和 AI 服务的集成。在 v25.1 中,new 和 methods 允许您以 JSON 格式保存和恢复控件布局。SaveLayoutToJson(Stream)
RestoreLayoutFromJson(Stream)
- C#
string filePath = "gridlayout.json";
void Form1_Load(object sender, EventArgs e) {if (File.Exists(filePath)) {using (var jsonStream = File.OpenRead(filePath))gridView1.RestoreLayoutFromJson(jsonStream);}
}void Form1_FormClosing(object sender, FormClosingEventArgs e) {using (var jsonStream = File.OpenWrite(filePath))gridView1.SaveLayoutToJson(jsonStream);
}
JSON 序列化可用于面向 .NET 8+ 和 .NET Framework 4.6.2+ 的项目。
圆角蒙皮面板
现在在 Visual Studio 工具箱中提供
我们圆角皮肤面板控件完全集成到 Visual Studio 设计器中,并且可以在设计时直接从 Toolbox 添加到表单中。
与标准面板不同,每当使用 WXI 皮肤时,我们的 RoundedSkinPanel 都会自动渲染各个 UI 元素(GridControl、TreeList、RichEditControl 等)周围的圆角和填充。对于其他 DevExpress 皮肤,RoundedSkinPanel 会回退到标准的矩形边框,而无需额外的填充。
文档
- C#
// Create a TreeList.
TreeList treeList = new TreeList() { Dock = DockStyle.Fill };
// Create a RoundedSkinPanel and set it to fill the form.
roundedSkinPanel = new RoundedSkinPanel() { Dock = DockStyle.Fill };
// Add the TreeList to the panel.
roundedSkinPanel.Controls.Add(treeList);
// Add the panel to the form.
this.Controls.Add(roundedSkinPanel);
重要
RoundedSkinPanel 旨在承载单个 UI 控件。如果您尝试添加多个,则在设计时将显示警告。对于复杂的布局/UI 要求,只需嵌套多个控件即可。RoundedSkinPanel
受 Outlook 启发的侧边导航
我们向 WinForms RibbonForm 添加了新属性,以复制 Microsoft Outlook for Windows 的侧边导航布局。
这导航控制property 将导航控件指定为侧边导航元素(如 AccordionControl、NavigationPane 或 ToolboxControl)。这NavigationControlLayoutMode属性将侧边导航与表单的标题对齐。对齐选项包括:
-
StretchToFormTitle
-
StretchToTop
- C#
using DevExpress.XtraBars.Ribbon;public partial class Form1 : RibbonForm {public Form1() {InitializeComponent();this.NavigationControl = accordionControl1;this.NavigationControlLayoutMode = RibbonFormNavigationControlLayoutMode.StretchToFormTitle;}
}
我们还更新了 WinFormsOutlook Inspired 应用程序演示:
安装 DevExpress WinForms 产品库.
条件格式
#表达式编辑器对自定义格式条件的支持
在 v25.1 中,用户可以通过自定义表达式创建高级条件格式规则(将新的FilterEditorAllowCustomExpressions属性激活 Conditional Formatting Rule Editor 中的 Expression Editor)。激活后,用户可以定义复杂的逻辑(例如[创建日期] > AddDays(LocalDateTimeToday(), -3)) (如您所料,在构建依赖于计算值、函数或高级比较的格式设置规则时,此功能/功能提供了更大的灵活性)。
可用于以下 DevExpress WinForms UI 组件:
- Data Grid
- Pivot Grid
- TreeList (树列表)
- Vertical Grid
#新过滤器
您现在可以根据应用的条件格式规则筛选数据。
用户可以从以下位置应用这些筛选器:
- Excel 样式的过滤器菜单
- Column Header Menu
- Filter Editor
文档
安装 DevExpress WinForms 产品库.
基于网格的组件
#立即发布更改(使用 DevExpress 就地数据编辑器时)
我们的新选项让您可以更好地控制 DevExpress 就地编辑器将值发布到底层数据源的方式/时间。InplaceModeImmediatePostChanges
启用后,以下就地编辑器会立即将更新的值发布到数据源(无需转移焦点):
- CheckEdit
- ToggleSwitch
- RadioGroup
- TrackBarControl
- RatingControl
- PopupBaseEdit descendants
您还可以将该属性设置为并使用InplaceModeImmediatePostChanges
WindowsFormsSettings.InplaceEditorUpdateMode属性来全局控制更新行为:DefaultBoolean.Default
- Immediate(立即的)- 修改后立即发布编辑值。
- Postponed(推迟)- 当单元格失去焦点时发布编辑值。
文档
#调整触摸板上的水平滚动
DevExpress WinForms 基于网格的控件(如 GridControl、TreeList、Gantt Control 和 VGridControl)支持使用触摸板平滑滚动。但是,某些用户在 Windows 设备上使用触摸板时可能会遇到倒置的水平滚动行为。
v25.1 引入了一个新的InvertHorizontalScrolling (反转水平滚动)全局选项,当使用触摸板或倾斜轮(具有 4 向滚动的鼠标或支持侧向倾斜的轨迹球)时,该选项在我们的 WinForms 基于网格的控件中反转当前的水平滚动方向。
在应用程序启动时启用该属性(在
Program.cs) 反转水平滚动方向。向右滑动手势和鼠标水平滚轮移动将内容向左滚动。InvertHorizontalScrolling
- C#
static void Main() {Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);WindowsFormsSettings.InvertHorizontalScrolling = DevExpress.Utils.DefaultBoolean.True;Application.Run(new Form1());
}
#ItemsView - 数据验证
v25.1 在 ItemsView 中包含 and 事件。ValidateRow
BeforeLeaveRow
数据编辑器
#步骤进度条 - UX 增强功能
我们改进了基于步骤的导航工作流的用户体验。在 v25.1 中,用户可以按如下方式与项目交互:StepProgressBar
- 单击项目以将其选中。
- 使用箭头键在项目之间移动焦点。
- 压进入或空间以选择项目。
新的 StepProgressBar API 包括:
- StepProgressBar.AllowUserInteraction- 指定用户是否可以与项目交互。
- StepProgressBarItem.AllowUserInteraction- 阻止用户与特定项目交互。
- StepProgressBar.ItemClick- 当用户单击 StepProgressBar 中的某个项并允许您取消选择时发生。
- C#
stepProgressBar1.AllowUserInteraction = true;
// ...
void StepProgressBar1_ItemClick(object sender, StepProgressBarItemClickEventArgs e) {if (IsDataSaved(e.Item)) return;if (XtraMessageBox.Show("You have unsaved changes. Would you like to save them?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes)e.Handled = true;
}
安装 DevExpress WinForms 产品库.
#SearchLookUpEdit - 同步查找面板文本
我们的 WinForms SearchLookUpEdit 允许用户为弹出视图指定查找面板文本,确保与查找过滤器文本财产。以前,修改该属性不会更新查找面板的文本框,从而导致搜索行为不一致。此增强功能可确保查找面板显示应用的实际过滤器。PopupView.FindFilterText
- C#
searchLookUpEdit.Properties.View.FindFilterText = "Mike";
#MemoEdit - 布局控件中的自动高度
我们的 WinForms MemoEdit 控件包括一个新的LayoutControlAutoHeightMode财产。此属性指定 MemoEdit 在放置在布局控制.可用的自动高度模式包括:
/Default
- MemoEdit 高度保持固定,不根据内容进行调整。如果内容超过可用高度,则会显示滚动条。None
- MemoEdit 高度会增加以适应内容,但不会在内容减少时降低。GrowOnly
- MemoEdit 高度会自动增加或减少以适应内容。GrowAndShrink
#CheckedListBoxControl - 自定义 SVG 校验图标
我们的 WinForms CheckedListBoxControl 现在支持用户定义(自定义)SVG 校验图标。在 v25.1 中,您可以为选中、未选中和灰显的项目状态指定唯一图标。此增强功能支持旨在匹配应用程序主题/UI 标准的自定义。
- C#
checkedListBoxControl1.CheckStyle = CheckStyles.UserDefined;
checkedListBoxControl1.ImageOptions.SvgImageChecked = svgImageCollection["checkedState"];
checkedListBoxControl1.ImageOptions.SvgImageUnchecked = svgImageCollection["uncheckedState"];
checkedListBoxControl1.ImageOptions.SvgImageSize = new System.Drawing.Size(16, 16);
#TokenEdit - 高级模式
v25.1 包括用于 WinForms TokenEdit 的新 API。使用这些 API,您可以自定义以下高级模式设置:
- 插入符号动画 (
)AllowCaretAnimation
- 选择动画 (
)AllowSelectionAnimation
- 选区颜色自定义 (
)SelectionColor
使用TokenEdit.Properties.AdvancedModeOptions属性以访问高级模式设置:
- C#
// Enable Advanced Mode.
tokenEdit.Properties.UseAdvancedMode = DefaultBoolean.True;
// Enable caret animation.
tokenEdit.Properties.AdvancedModeOptions.AllowCaretAnimation = DefaultBoolean.True;
// Animate selection.
tokenEdit.Properties.AdvancedModeOptions.AllowSelectionAnimation = DefaultBoolean.True;
// Set selection color.
tokenEdit.Properties.AdvancedModeOptions.SelectionColor = Color.Yellow;
我们还实现了一个新的QueryAdvancedMode 查询高级模式static 事件。此事件对项目中的每个 TokenEdit 控件触发,并允许您根据自己的首选项配置高级模式设置。
- C#
using DevExpress.Utils;
using DevExpress.XtraEditors;
using System;
using System.Drawing;
using System.Windows.Forms;namespace DXApplication {internal static class Program {[STAThread]static void Main() {Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);TokenEdit.QueryAdvancedMode += TokenEdit1_QueryAdvancedMode;Application.Run(new Form1());}static void TokenEdit1_QueryAdvancedMode(object sender, TokenEdit.QueryAdvancedModeEventArgs e) {if(e.ParentForm is Form1) {// Enable Advanced Mode.e.UseAdvancedMode = DefaultBoolean.True;// Set the selection colore.Editor.Properties.AdvancedModeOptions.SelectionColor = Color.Yellow;}}}
}
AI 聊天控制
#文件附件
用户现在可以将文件直接附加到他们的聊天消息中。这使 AI 能够分析文档内容(例如文本文件、PDF、图像)并提供更多上下文感知响应。
启用该属性以允许用户附加文件,并根据您的项目要求(最大文件大小、允许的文件类型/扩展名、用户可以附加到消息的最大文件数)配置相关设置:FileUploadEnabled
- C#
aiChatControl1.FileUploadEnabled = DevExpress.Utils.DefaultBoolean.True;
#提示建议
为了帮助用户入门或探索新的可能性,DevExpress AI Chat Control 可以显示提示建议。
使用该方法提供智能建议:SetPromptSuggestions
- C#
using DevExpress.AIIntegration.Blazor.Chat.WebView;aiChatControl1.SetPromptSuggestions(new List<PromptSuggestion>(){new PromptSuggestion(title: "Birthday Wish",text: "A warm and cheerful birthday greeting message.",prompt: "Write a heartfelt birthday message for a close friend."),new PromptSuggestion("Thank You Note","A polite thank you note to express gratitude.","Compose a short thank you note to a colleague who helped with a project.")
});
#停止响应
用户现在只需单击一下即可中断冗长的 AI 响应。
Accordion(手风琴)
#徽章和提示
我们将 WinForms Accordion Control 与 Adorner UI 管理器集成在一起,以帮助显示徽章/提示并突出显示特定的 Accordion UI 元素。
文档
- C#
using System.Drawing;
using DevExpress.Utils.VisualEffects;
// ...
Badge badgeInbox;
public Form1() {InitializeComponent();badgeInbox = new Badge();// Assign the badge to the 'Inbox' accordion item.badgeInbox.TargetElement = accordionItemInbox;// Specify badge text.badgeInbox.Properties.Text = "17";// Specify badge location and offset.badgeInbox.Properties.Location = ContentAlignment.TopLeft;badgeInbox.Properties.Offset = new Point(85, 6);// Customize badge appearance.badgeInbox.Appearance.BackColor = Color.Gray;badgeInbox.Appearance.BorderColor = Color.Gray;badgeInbox.Appearance.ForeColor = Color.White;badgeInbox.Appearance.Font = new Font("Tahoma", 8.25F, FontStyle.Bold);// Add the badge to the AdornerUIManager.adornerUIManager1.Elements.Add(badgeInbox);
}
安装 DevExpress WinForms 产品库.
Map Control(地图控件)
#Azure Maps - 新演示
以下演示已更新为使用新的 Azure Maps 数据提供程序。我们鼓励您检查我们的实施,以简化您向 Azure Maps 的过渡:
- Map Elements
- Gpx Data Adapter
- Sales Dashboard
- Clustering
- Map Editor
- Photo Gallery
- Items Moving
- Vector Item Data Source
- Bubble Charts
- Coordinate Systems
- Geo Shape Image
安装 DevExpress WinForms 产品库.
Ribbon and Bars
#BarToggleSwitchItem - 切换开关宽度
在 v25.1 中,您可以指定切换开关栏项宽度。使用EditorToThumbWidthRatio属性来设置项相对于 Thumb 宽度的总宽度。
Visual Studio 2010、Office 2013 和其他具有类似视觉样式的外观将缩略图渲染为矩形。为了支持这些皮肤,我们添加了ThumbWidth (拇指宽度)财产。在这些外观中,切换开关编辑器的总宽度计算为 和 属性值的乘积。ThumbWidth
EditorToThumbWidthRatio
#手柄栏项右键单击
WinForms Bar Manager 和 Ribbon Control 现在支持对 Bar 项进行右键单击处理。新活动包括:
- RibbonControl.ItemRightClick
- BarManager.ItemRightClick
- BarItem.ItemRightClick
我们还引入了一个新的 event 参数,允许您识别按下的鼠标按钮。e.MouseButton
#Ribbon - Disable Double-Click Minimization
现在,您可以通过双击来最小化 DevExpress WinForms 功能区。此行为由允许 MinimizeRibbonOnDoubleClick财产。将此属性设置为假以禁用双击最小化。
#Maximize/Minimize Ribbon
新的 API 包括:
- 最大化功能区 (RibbonPage)- 展开最小化的功能区。
- RibbonControl.AllowMinimizeRibbonOnDoubleClick- 指定用户是否可以通过双击页眉来最小化功能区。
#识别条形项目和条形链接
新的 API 包括:
- BarManager.GetItemAt(点)- 在指定的屏幕坐标处标识 bar 项。
- BarManager.GetLinkAt(点)- 标识指定屏幕坐标处的 BarItemLink。
- C#
barManager.ItemClick += (sender, e) => {BarItem item = barManager.GetItemAt(Cursor.Position);BarItemLink itemLink = barManager.GetLinkAt(Cursor.Position);Debug.WriteLine(item.Caption);Debug.WriteLine(itemLink.Caption);
};
PDF 查看器
#AI 驱动的行为
您现在可以在 DevExpress 中使用 AI 驱动的 Summarize、Translate 和 Ask AI 功能WinForms PDF 查看器.您可以使用 PDF 查看器的上下文菜单访问所需的 AI作。
WinForms PDF Viewer AI 驱动的行为与我们 WinForms 产品线中的其他 AI 扩展具有相同的先决条件,并利用相同的集成机制。
有关其他信息,请参阅以下帮助主题:适用于 WinForms 的 DevExpress AI 驱动的扩展.
安装 DevExpress WinForms 产品库.
#保存时保留压缩的对象流
我们的新压缩引擎保留了 PDF 对象流的原始(压缩)状态。
#PDF 修订 API
v25.1 包含用于创建和管理 PDF 密文注释的新 API。这项新功能允许您从文档中隐藏或删除敏感或私人内容,并在编辑区域添加彩色文本叠加。
修订过程包括两个步骤:
- 在 PDF 页面区域中创建具有所需外观的密文批注(如果您希望隐藏内容但为其他用户保留内容,则很有用)。
- 使用批注清除内容,并使用指定的外观设置应用叠加。在这种情况下,所有隐藏的内容都将被删除。
注意
密文支持可通过 PDF Facade API (DevExpress.Pdf.PdfDocument立面类)。此类在程序集中定义。将此程序集添加到项目中,或安装DevExpress.Docs.v25.1.dll
DevExpress.Document.Processor从脱机包源获取 NuGet 包以使用成员。PdfDocumentFacade
您需要DevExpress Office 文件 API 订阅或DevExpress 通用订阅在生产代码中使用此类。
在代码中创建和应用密文注释
要创建密文注释,请执行以下步骤:
- 使用PdfViewerControl.GetDocumentFacadeextension 方法获取DevExpress.Pdf.PdfDocument立面实例。
- 从PdfDocumentFacade.Pages收集。
- 调用PdfPageFacade.AddRedactAnnotation方法。此方法返回PdfRedactAnnotationFacade对象,并允许您修改密文批注的以下外观设置:背景颜色、叠加文本、文本字体设置(字体名称、颜色、大小和样式)、文本重复和对齐方式。
我们的新 API 允许您应用以下注释:
- 单个修订注释:PdfRedactAnnotationFacade.应用
- 特定页面的所有密文注释:PdfPageFacade.ApplyRedact注释
- 整个文档中的所有密文注释:PdfDocumentFacade.ApplyRedact注释
您还可以使用DevExpress.Pdf.PdfClearContentOptions以指定在应用密文时要删除的内容类型(文本、图形、图像或批注)。
- C#
pdfViewer.LoadDocument("Demo.pdf");
//...
PdfDocumentFacade documentFacade = pdfViewer.GetDocumentFacade();
PdfRectangle pageCropBox = pdfViewer.GetPageInfo(0).CropBox;
PdfRectangle redactBounds =new PdfRectangle(0, pageCropBox.Height-50, 200, pageCropBox.Height);// Add a redaction annotation at the top left corner of the first document page.
PdfRedactAnnotationFacade redactAnnotation =documentFacade.Pages[0].AddRedactAnnotation(redactBounds);
redactAnnotation.Author = "Jane Doe";
// Setup redaction annotation appearance
redactAnnotation.FillColor = new PdfRGBColor(0, 0, 0);
redactAnnotation.FontColor = new PdfRGBColor(1, 1, 1);
redactAnnotation.FontName = "Calibri";
redactAnnotation.FontSize = 0; // enables font auto-size
redactAnnotation.OverlayText = "Classified";
redactAnnotation.TextJustification = PdfTextJustification.Centered;
redactAnnotation.RepeatText = false;// Apply the redaction annotation.
redactAnnotation.Apply();
以下示例在 PDF 文档中选择一个区域(使用我们的 PDF 查看器时),并将密文批注应用于此区域:
适用于 WinForms 的 PDF 查看器 - 使用查看器坐标添加密文注释
电子表格控制
#OLE 对象
这DevExpress WinForms 电子表格控件现在支持 OLE 对象。OLE(对象链接和嵌入)允许您链接外部文件并将数据(电子表格、PDF、邮件消息、演示文稿等)嵌入到 Excel 文档中。
使用 OLE 对象支持,您可以执行以下作:
- 创建 OLE 对象,用于存储指向外部文件的链接或将这些文件中的数据嵌入到文档中;
- 获取 OLE 对象属性;
- 从文档中提取 OLE 对象数据;
- 从文档中删除 OLE 对象;
- 将带有 OLE 对象图标的文档打印并导出为 PDF 和图像格式;
- 加载和保存包含 OLE 对象的文档,而不会丢失内容。
OLE 对象由接口表示。作为唯一的文档形状,OLE 对象从基本界面继承所有设置。形状设置定义 OLE 对象图标的外观、位置和内部对象属性(包括名称、图标大小、工作表中的图标位置、替换文本等)。OleObject
Shape
要访问工作表中的 OLE 对象,请使用Worksheet.OleObjects收集。它们也可以通过底座获得Worksheet.Shapes收集。OleObjectCollection.AddLinkedOleObject和OleObjectCollection.AddEmbeddedOleObject方法允许您在工作表中创建新的链接或嵌入的 OLE 对象。
- C#
Worksheet worksheet = spreadsheetControl.ActiveWorksheet;
CellRange oleIconRange = worksheet.Range["B4:D6"];
SpreadsheetImageSource oleIcon = SpreadsheetImageSource.FromFile("oleIcon.png");// Create linked OLE object.
OleObject oleObjectLinked = worksheet.OleObjects.AddLinkedOleObject(oleIconRange, "package.pdf", OleObjectType.Package, oleIcon);// Create embedded OLE object from byte array.
byte[] sourceData = File.ReadAllBytes("package.pdf");
OleObject oleObjectEmbedded1 = worksheet.OleObjects.AddEmbeddedOleObject(oleIconRange, sourceData, OleObjectType.Package, oleIcon);// Create embedded OLE object from file stream.
using (var stream = File.OpenRead("package.pdf")) {OleObject oleObjectEmbedded2 = worksheet.OleObjects.AddEmbeddedOleObject(oleIconRange, stream, OleObjectType.Package, oleIcon);
}
您还可以提取和分析链接数据和嵌入数据。使用OleObject.InsertType属性来确定 OLE 对象类型(链接或嵌入)。OleObject.AsLinkedContent和OleObject.AsEmbeddedContent方法允许您根据 OLE 对象类型提取其他信息。对于链接对象,您可以使用OleObjectLinkedContent.FileName财产。对于嵌入对象,您可以使用OleObjectEmbeddedContent.GetRawData方法,或使用OleObjectEmbeddedContent.SaveAs方法。
- C#
Worksheet worksheet = spreadsheetControl.ActiveWorksheet
OleObject oleObject = worksheet.OleObjects[0];
if(oleObject.InsertType == OleObjectInsertType.Linked)
{OleObjectLinkedContent linkedContent = oleObject.AsLinkedContent();string linkedFileName = linkedContent.FileName;
}
if(oleObject.InsertType == OleObjectInsertType.Embedded)
{OleObjectEmbeddedContent embeddedContent = oleObject.AsEmbeddedContent();byte[] oleRawData = embeddedContent.GetRawData();if (oleObject.Type == OleObjectType.AdobeAcrobatDocument)using (FileStream stream = new FileStream("embedded_document.pdf", FileMode.Create, FileAccess.Write))embeddedContent.SaveAs(stream);
}
您还可以从电子表格中删除 OLE 对象。使用OleObject.Delete,OleObjectCollection.Remove或OleObjectCollection.RemoveAt方法删除单个 OLE 对象,或使用OleObjectCollection.Clear方法从工作表中删除所有 OLE 对象。
- C#
OleObject oleObject = worksheet.OleObjects[0];// Remove the current OLE object.
oleObject.Delete();
// or
worksheet.OleObjects.Remove(oleObject);// Remove all OLE objects in the collection.
worksheet.OleObjects.Clear();
注意
OLE 对象支持仅以基于 OpenXML 的文件格式(XLSX、XLSM、XLTX 和 XLTM)提供。
文档
如何:使用 RichEditControl API 创建可填写的 PDF 表单
富文本编辑器
#从右到左 (RTL) 引擎增强功能
我们增强了从右到左文本渲染引擎(改进了段落、页眉和页脚、编号列表、表格和形状中的文本顺序,其中包含双向文本,包括混合的从右到左和从左到右文本块)。
当您通过用户界面或代码生成 PDF 文件、图像或打印输出时可用。
#CJK(中文、日文和韩文)文本换行
v25.1 添加了 CJK 文本换行和换行规则支持。在以前的版本中,我们的 Rich Text Editor 将拉丁文本换行规则(依赖于空格字符和标点符号)应用于中文、日语和韩语文本。
新的环绕规则可正确地在文档段落、页眉和页脚、表格和形状的单个字符之间应用换行符。使用 CJK 文本环绕规则的文档现在可以打印/导出为具有适当文本布局的 PDF 和图像格式。
#PDF 导出 - 将 Word 内容控件转换为 PDF AcroForm 域
我们扩展了Word 文档转 PDF导出引擎,内置了 Word 内容控件到 PDF AcroForm 字段的转换。
DevExpress 字处理工具会自动转换以下内容控件类型:
- Plain Text
- Rich Text
- Picture
- Check Box
- Combo Box
- Drop-Down List
- Date Picker
注意
Building Block 和 Repeating Section 控件导出为常规文本。
由于 PDF 格式限制,从富文本内容控件生成的 PDF 文本字段使用原始富文本内容控件的第一个单词的格式。
拆分页面或包含复杂对象(如表格)的 RTF 内容控件将导出为常规文本。
要启用此功能,您必须:
- 使用 DevExpress WinForms 富文本编辑器加载带有内容控件的 Word 文件或在文档中生成内容控件。
- 创建一个Pdf导出选项实例。
- 启用PdfExportOptions.ExportEditingFieldsToAcroForms财产。
- 调用导出到 Pdf方法。
PdfExportOptions
您还可以使用对话框从用户界面激活此功能。Print Preview -> PDF Export Options
- C#
using DevExpress.XtraPrinting;
using DevExpress.XtraRichEdit;richEditControl.LoadDocument("input_content_controls.docx");
PdfExportOptions options = new PdfExportOptions();
options.ExportEditingFieldsToAcroForms = true;
richEditControl.ExportToPdf("output_with_acroform.pdf", options);
#比较 Word 文档
您现在可以以编程方式比较两个 Word 文档。我们的新扩展方法允许您执行以下作:CompareDocumentExtensions.Compare
- 识别两个文档版本之间的更改,并生成包含修订版的 Word 输出。
- 比较文档文本和格式(包括区分大小写)。
- 比较文档页眉、页脚和文本框中的内容。
- 设置输出修订的作者/日期。
- 在单词或字符级别比较内容。
- 将包含修订的文档作为新的 Document 实例返回以供进一步处理(或自动将输入文档替换为修订后的内容)。
注意
输入文档不得包含文档修订。否则,该方法将引发异常。Compare
- C#
richEditControl.LoadDocument("FirstLook_original.docx");
Document originalDocument = richEditControl.Document;RichEditDocumentServer wordProcessor = new RichEditDocumentServer();
wordProcessor.LoadDocument("FirstLook_revised.docx");
Document revisedDocument = wordProcessor.Document;// Setup compare options, compare two documents,
// and add revisions to the RichEditControl document.
Document docWithRevisions = originalDocument.Compare(revisedDocument, new CompareDocumentOptions()
{Author = "Jane Doe",DateTime = DateTime.Now,ComparisonLevel = ComparisonLevel.Word,CompareCaseChanges = false,CompareFormatting = true,CompareHeadersAndFooters = true,CompareTextBoxes = true
}, ComparisonTargetType.Original);
注意
扩展方法在 DevExpress.Docs.v25.1.dll 程序集中定义。将此程序集添加到项目中,或安装CompareDocumentExtensions.Compare
DevExpress.Document.ProcessorNuGet Package 以使用我们的方法。CompareDocumentExtensions.Compare
重要
您需要一个活跃的DevExpress Office 文件 API 订阅或DevExpress 通用订阅在生产代码中使用此类。
XtraMessageBox
#显示在 Windows 任务栏和自定义开始位置
借助新功能,您可以:
- 在 Windows 任务栏中显示 DevExpress 消息框,确保用户可以轻松访问它。
- 定义 Message Box 在屏幕上的起始位置。
- C#
void messageButton_Click(object sender, EventArgs e) {XtraMessageBoxArgs args = new XtraMessageBoxArgs() {Caption = "Tip",Text = "Hello DevExpress!",Buttons = new DialogResult[] { DialogResult.OK },};args.ImageOptions.SvgImage = svgImageCollection1["info"];args.ImageOptions.SvgImageSize = new Size(32, 32);args.Showing += Args_Showing;XtraMessageBox.Show(args);
}
void Args_Showing(object sender, XtraMessageShowingArgs e) {// Get the screen working area.Rectangle workingArea = Screen.PrimaryScreen.WorkingArea;// Calculate bottom-right position.int x = workingArea.Right - e.MessageBoxForm.Width;int y = workingArea.Bottom - e.MessageBoxForm.Height;// Define message box start position.e.MessageBoxForm.StartPosition = FormStartPosition.Manual;e.MessageBoxForm.Location = new Point(x, y);// Display the message box in the Windows taskbar.e.MessageBoxForm.ShowInTaskbar = true;
}