DevExpress WinForms拥有180+组件和UI库,能为Windows Forms平台创建具有影响力的业务解决方案。DevExpress WinForms能完美构建流畅、美观且易于使用的应用程序,无论是Office风格的界面,还是分析处理大批量的业务数据,它都能轻松胜任!
DevExpress下一个主要更新(v25.1)将在几个月后发布,正如我们之前提到的那样,新的桌面开发标准(. NET Core、AI、可访问性)仍然是重点关注的领域。在本文中,我们为大家介绍了.DevExpress WinForms数据网格中即将新增的AI驱动的语义搜索,欢迎下载最新版控件体验!
DevExpress技术交流群11:749942875 欢迎一起进群讨论
WinForms Data Grid中由AI驱动的语义搜索
DevExpress WinForms Data Grid(v25.1)将提供增强的搜索体验,并允许用户在大型数据集中更快/更准确地定位相关数据。Data Grid(数据网格)利用自然语言处理(NLP)来分析精确关键字匹配之外的搜索查询,通过解释同义词和上下文含义,DevExpress Data Grid将提供更精确的搜索结果。
一旦启用了人工智能驱动的语义搜索,搜索框中就会出现一个下拉按钮。弹出式菜单允许用户指定搜索模式:标准、语义或混合(标准和语义搜索的组合)。

您可以在“过滤”或“搜索”模式下使用语义搜索,在“搜索”模式下,网格突出显示相关数据行,以便更灵活/直观地发现数据:

语义搜索需要使用额外的DevExpress NuGet包:
- DevExpress.AIIntegration.SemanticSearch
- DevExpress.AIIntegration.WinForms.SemanticSearch
为了在DevExpress WinForms Data Grid(数据网格)中启用AI支持的语义搜索,您必须注册一个嵌入生成器,提供一个矢量存储/数据库,将新SemanticSearchBehavior连接到网格,并配置操作设置(例如,嵌入生成器、矢量存储、矢量存储中的记录类型、数据源关键字段、搜索模式、搜索准确性、最大结果数量等):

您可以使用任何实现了IVectorStore接口的向量存储来存储嵌入。有关更多信息,请参阅以下主题:Available vector database solutions。
下面的代码片段初始化向量,它在内存中创建一个矢量存储来存储矢量化记录(用于演示目的)。生产型AI应用使用向量数据库和服务来提高相关性,async void Form1_Shown(object sender, EventArgs e)
{ try { await Initialize(); } catch(Exception ex) { MessageBox.Show(ex.ToString()); } } // Define a record stored in the vector store for semantic search class VectorStoreRecord { // A unique identifier for the record in a vector store [VectorStoreRecordKey] public string Key { get; set; } // Text content associated with the record [VectorStoreRecordData] public string ItemDescription { get; set; } // Numerical vector representation of the record // Specifies how vector data is stored and compared in a vector store // Ollama produces 768-dimensional vectors [VectorStoreRecordVector(768, DistanceFunction.CosineSimilarity)] public ReadOnlyMemory<float> Vector { get; set; } } async Task Initialize() { // Initialize an embedding generator to convert text into numerical vectors // This example uses the Ollama embedding generator. var embeddingGenerator = new OllamaEmbeddingGenerator(new Uri("http://localhost:11434/"), "nomic-embed-text"); /* The following code uses an Azure OpenAI embedding model. * You can use the 'text-embedding-3-small' model that produces 1536-dimensional vectors. * Modify the 'VectorStoreRecordVector' attribute for the 'VectorStoreRecord.Vector'. * var embeddingGenerator = new AzureOpenAIClient( * new Uri(AzureOpenAIEndPoint), * new AzureKeyCredential(AzureOpenAIKey)) * .AsEmbeddingGenerator(ModelId); */ // Create an in-memory vector store to store vectorized records var vectorStore = new InMemoryVectorStore(); // Retrieve the default AI container var container = AIExtensionsContainerDesktop.Default; // Register the embedding generator in the AI container container.AddEmbeddingGenerator(embeddingGenerator); // Register the vector store in the AI container container.AddVectorStore(vectorStore); // Create and populate the vector store with vectorized data items await container.CreateVectorStoreCollectionAsync<DataItem, VectorStoreRecord>( // Retrieve all items to be indexed dataSource: DataItem.GetAllItems(), // Specify the collection name in the vector store vectorStoreCollectionName: "DataItems", // Extract the text content from each item to be transformed into a vector vectorizableContentGetter: item => item.Name + " - " + item.Description); }
JSON序列化
DevExpress WinForms UI控件现在支持基于JSON的布局序列化,这是XML的替代方案,可以简化与现代web和AI服务的集成。在v25.1中,一个新的SaveLayoutToJson(流)方法允许您以JSON格式保存和恢复控件布局。
JSON序列化可用于.NET 8+和.NET Framework 4.6.2+的项目。
string filePath = "gridlayout.json"; void Form1_Load(object sender, EventArgs e) { if (File.Exists(filePath)) { using (var jsonStream = File.OpenRead(filePath)) gridView.RestoreLayoutFromJson(jsonStream); } } void Form1_FormClosing(object sender, FormClosingEventArgs e) { using (var jsonStream = File.OpenWrite(filePath)) gridView.SaveLayoutToJson(jsonStream); }
基于WinForms Grid控件的增强
ItemsView - 数据验证
EAP版本包括ItemsView中的新的ValidateRow和BeforeLeaveRow事件。
调整触控板的水平滚动
DevExpress基于网格的控件(如GridControl、TreeList、Gantt Control和VGridControl)支持用触摸板平滑滚动。然而,一些用户在使用Windows设备上的触摸板时可能会遇到水平滚动的倒转行为。
v25.1引入了一个新的InvertHorizontalScrolling选项,当使用触摸板时,它可以在DevExpress WinForms基于网格的控件中反转当前的水平滚动方向。
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); WindowsFormsSettings.InvertHorizontalScrolling = DefaultBoolean.True; Application.Run(new Form1()); }
更多产品资讯及授权,欢迎来电咨询:023-68661681
更多DevExpress线上公开课、中文教程资讯请上中文网获取
关于慧都科技
慧都科技是专注软件工程、智能制造、石油工程三大行业的数字化解决方案服务商。在软件工程领域,我们提供开发控件、研发管理、代码开发、部署运维等软件开发全链路所需的产品,提供正版授权采购、技术选型、个性化维保等服务,帮助客户实现技术合规、降本增效与风险可控。
慧都科技是DevExpress的中国区的合作伙伴,DevExpress作为用户界面领域的优秀产品,帮助企业高效构建权限管理、数据可视化(如网格/图表/仪表盘)、跨平台系统(WinForms/ASP.NET/.NET MAUI)及行业定制解决方案,加速开发并强化交互体验。
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/5137.html
相关产品: DevExpress WinForms Subscription, DevExpress Universal Subscription,