windowsforms-devexpress-dot-aiintegration-dot-winforms-8ee88594.md
Enables AI-driven semantic search in GridControl, GridLookUpEdit, and SearchLookUpEdit controls.
Namespace : DevExpress.AIIntegration.WinForms
Assembly : DevExpress.AIIntegration.WinForms.SemanticSearch.v25.2.dll
NuGet Package : DevExpress.AIIntegration.WinForms.SemanticSearch
public sealed class SemanticSearchBehavior :
BehaviorWithEvents<ISemanticSearchBehaviorSource>,
ISemanticSearchCaller
Public NotInheritable Class SemanticSearchBehavior
Inherits BehaviorWithEvents(Of ISemanticSearchBehaviorSource)
Implements ISemanticSearchCaller
Warning
This help topic describes v25.1.3 (RTM), which includes the updated and improved semantic search API. If you are using the BETA version (v25.1.2), the API differs. See our demo project for details on how to activate and configure semantic search in BETA.
Run Demo: Semantic Search (BETA)
BehaviorManager component from the Toolbox onto a Form.SemanticSearchBehavior and attach it to a DevExpress UI control (GridControl, GridLookUpEdit, or SearchLookUpEdit).The following code snippet activates semantic search for a GridLookUpEdit:
public Form1() {
InitializeComponent();
gridLookUpEdit1.Properties.DataSource = DataHelper.Items;
gridLookUpEdit1.Properties.DisplayMember = "Model";
gridLookUpEdit1.Properties.ValueMember = "Id";
behaviorManager1.Attach<SemanticSearchBehavior>(gridLookUpEdit1.Properties.View, behavior => {
behavior.Properties.VectorCollectionName = "Cars";
behavior.Properties.DataSourceKeyField = "Id";
behavior.Properties.SearchResultCount = 10;
behavior.Properties.SearchMode = ControlSearchMode.Semantic;
// It is implied, that Cosine Distance filtering is used for the vector store.
// Lower = more similar
behavior.Properties.ScoreThreshold = 0.5D;
behavior.Properties.ScoreThresholdFilter = ScoreThresholdFilter.LessOrEqual;
});
}
Note
Call the BehaviorInitializer.Initialize() method at application startup if your project targets the .NET Framework and you create AI-powered behaviors in code. Otherwise, an exception is thrown.
internal static class Program {
[STAThread]
static void Main() {
//...
// The Initialize() method forcibly initializes the behavior manager in .NET Framework apps.
DevExpress.AIIntegration.WinForms.BehaviorInitializer.Initialize();
Application.Run(new Form1());
}
}
See the following help topic for additional information: Semantic Search.
Object DevExpress.Utils.MVVM.BehaviorBase DevExpress.Utils.Behaviors.Behavior DevExpress.Utils.Behaviors.Behavior<DevExpress.AIIntegration.WinForms.ISemanticSearchBehaviorSource> DevExpress.Utils.Behaviors.BehaviorWithEvents<DevExpress.AIIntegration.WinForms.ISemanticSearchBehaviorSource> SemanticSearchBehavior
See Also