windowsforms-405608-ai-powered-extensions-prompt-to-expression.md
Prompt to Expression converts natural language into valid filter and unbound column expressions for data-aware WinForms controls. Instead of writing complex expressions, users describe the desired logic in plain text:
Sample Filter Expression_Display orders expected to arrive within 7 days.Sample Unbound Column Expression_Compute total amount.
The system sends the prompt to the configured AI service, which generates a valid expression for the control. The Expression Editor or Filter Editor displays and validates the result immediately.
Run Demo: Prompt to Expression
| Control | Editor | Supported |
|---|---|---|
| GridControl | Expression Editor / Filter Editor | Yes |
| TreeList | Expression Editor / Filter Editor | Yes |
| VGridControl | Expression Editor / Filter Editor | Yes |
Note
The user opens the Filter Editor.
The user enters an intent in the Prompt to Expression field and clicks Send.
AI generates a filter expression. The Filter Editor displays the result.
The user opens the Expression Editor for an unbound column.
The user enters an intent in the Prompt to Expression field and clicks Send.
AI generates the expression. The Expression Editor displays the result.
.NET 8 SDK / .NET Framework v4.7.2
DevExpress.AIIntegration.WinFormsDevExpress.Win.Design (design-time infrastructure)See the following help topics for information on how to obtain the DevExpress NuGet Feed and install DevExpress NuGet packages:
See the following help topic for information on required NuGet packages and system requirements: Register an AI Client.
The following code snippet registers the Azure OpenAI client:
using Microsoft.Extensions.AI;
using DevExpress.AIIntegration;
internal static class Program {
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
IChatClient azureChatClient = new Azure.AI.OpenAI.AzureOpenAIClient(new Uri(AzureOpenAIEndpoint),
new System.ClientModel.ApiKeyCredential(AzureOpenAIKey))
.GetChatClient(ModelId).AsIChatClient();
AIExtensionsContainerDesktop.Default.RegisterChatClient(azureChatClient);
// Uncomment the following line if your project targets the .NET Framework and
// you create AI-powered behaviors in code.
// DevExpress.AIIntegration.WinForms.BehaviorInitializer.Initialize();
Application.Run(new Form1());
}
static string AzureOpenAIEndpoint { get { return Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT"); } }
static string AzureOpenAIKey { get { return Environment.GetEnvironmentVariable("AZURE_OPENAI_APIKEY"); } }
static string ModelId { get { return "MODEL_NAME"; } }
}
Imports Microsoft.Extensions.AI
Imports DevExpress.AIIntegration
Friend Module Program
<STAThread>
Sub Main()
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
' Register Azure.OpenAI
Dim azureChatClient As IChatClient = New Azure.AI.OpenAI.AzureOpenAIClient(New Uri(AzureOpenAIEndpoint),
New System.ClientModel.ApiKeyCredential(AzureOpenAIKey)).
GetChatClient(ModelId).AsIChatClient()
AIExtensionsContainerDesktop.Default.RegisterChatClient(azureChatClient)
' Uncomment the following line if your project targets the .NET Framework and
' you create AI-powered behaviors in code.
' DevExpress.AIIntegration.WinForms.BehaviorInitializer.Initialize()
Application.Run(New Form1())
End Sub
Private ReadOnly Property AzureOpenAIEndpoint() As String
Get
Return Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")
End Get
End Property
Private ReadOnly Property AzureOpenAIKey() As String
Get
Return Environment.GetEnvironmentVariable("AZURE_OPENAI_APIKEY")
End Get
End Property
Private ReadOnly Property ModelId As String
Get
Return "MODEL_NAME"
End Get
End Property
End Module
GridControl, VGridControl, or TreeList). You can do this at design time or in code:| Property | Description |
|---|---|
Target | Specifies the attached control (GridControl, VGridControl, or TreeList). |
| RetryAttemptCount | Specifies the number of additional attempts the AI makes to regenerate an expression if the previous result is invalid. |
| Temperature | Specifies creativity in AI responses. Set 1 for models (for example, GPT-5, o1, and o3 series) that ignore this parameter to avoid compatibility errors. |
| PromptAugmentation | Appends additional instructions to each user prompt. |
| AugmentWithFunctionInfo | Injects supported functions and operators into each user prompt. Increases accuracy. Adds about 4,000 tokens per request (adds cost). Default : true. |
Runtime ScopeDesign-time Filter and Expression Editors are not supported.Legacy EditorsLegacy Expression and Filter Editors do not integrate AI.Retry PolicyUse the RetryAttemptCount property to specify how many times the system retries expression generation.Error HandlingExpression and Filter Editors validate the generated expression and display an error message if all attempts produce invalid exceptions.