Back to Devexpress

Prompt to Report Behavior in the WinForms Report Designer (CTP)

xtrareports-405460-ai-powered-functionality-desktop-reporting-prompt-to-report-in-win-report-designer.md

latest14.1 KB
Original Source

Prompt to Report Behavior in the WinForms Report Designer (CTP)

  • Nov 11, 2025
  • 9 minutes to read

This help topic describes how to integrate the AI-powered Prompt-to-Report functionality into the Report Designer. Once integrated, users can create reports by specifying a prompt (report description in natural language).

Important

The Prompt-to-Report functionality is currently available as a community technology preview (CTP).

Prerequisites

.NET8+ or NET Framework v4.7.2+

Install NuGet Packages

Install the following NuGet packages:

See the following help topics for information on how to obtain the DevExpress NuGet Feed and install DevExpress NuGet packages:

Register AI Client

The following code snippet registers an Azure OpenAI client at application startup:

csharp
using Azure.AI.OpenAI;
using DevExpress.AIIntegration;
using Microsoft.Extensions.AI;
using System.ClientModel;

internal static class Program {
    static string AzureOpenAIEndpoint { get { return "AZURE_OPENAI_ENDPOINT"; } }
    static string AzureOpenAIKey { get { return "AZURE_OPENAI_APIKEY"; } }
    static string DeploymentName { get { return "MODEL_NAME"; } } // For example, gpt-4.1.
    [STAThread]
    static void Main(){
        IChatClient client = new AzureOpenAIClient(
            new Uri(AzureOpenAIEndpoint),
            new ApiKeyCredential(AzureOpenAIKey))
                .GetChatClient(DeploymentName).AsIChatClient(); 
        AIExtensionsContainerDesktop.Default.RegisterChatClient(client);
        ApplicationConfiguration.Initialize();
        Application.Run(new Form1());
    }
}
vb
Imports Azure.AI.OpenAI
Imports DevExpress.AIIntegration
Imports Microsoft.Extensions.AI
Imports System.ClientModel

Friend Module Program
    Private ReadOnly Property AzureOpenAIEndpoint() As String
        Get
            Return "AZURE_OPENAI_ENDPOINT"
        End Get
    End Property
    Private ReadOnly Property AzureOpenAIKey() As String
        Get
            Return "AZURE_OPENAI_APIKEY"
        End Get
    End Property
    Private ReadOnly Property DeploymentName() As String
        Get
            Return "MODEL_NAME"
        End Get
    End Property
        <STAThread>
        Sub Main()
        Dim client As IChatClient = (New AzureOpenAIClient(New Uri(AzureOpenAIEndpoint), New ApiKeyCredential(AzureOpenAIKey))).GetChatClient(DeploymentName).AsIChatClient()
        AIExtensionsContainerDesktop.Default.RegisterChatClient(client)
        ApplicationConfiguration.Initialize()
        Application.Run(New Form1())
        End Sub
End Module

Tip

How to Register OpenAI, Azure OpenAI, Ollama, and Semantic Kernel Clients.

Create and Configure a Behavior Object

Follow the steps below to attach a Prompt-to-Report Behavior to the WinForms Report Designer control at design time:

  1. Drop the BehaviorManager component from the Toolbox onto a Form.

  2. For .NET Framework Projects: Use the Register AI-powered Behaviors option in the BehaviorManager’s smart tag menu to add the “AI-Powered Behaviors” submenu with report behaviors to BehaviorManager.

  3. Use the Edit Behaviors option in the BehaviorManager’s smart tag menu to access the behavior collection.

  4. Add a Report Prompt-to-Report Behavior and specify its settings:

Create and Configure a Behavior Object in Code

The following code registers a ReportPromptToReportBehavior and attaches it to the WinForms Report Designer control:

csharp
using DevExpress.AIIntegration.WinForms.Reporting;
// ...
public partial class Form1 : Form {
    public Form1() {
        InitializeComponent();
        behaviorManager1.Attach<ReportPromptToReportBehavior>(reportDesigner1, behavior => {
           // ...
        });
    }
}
vb
Imports DevExpress.AIIntegration.WinForms.Reporting
' ...
Partial Public Class Form1
    Inherits Form

    Public Sub New()
        InitializeComponent()
        behaviorManager1.Attach(Of ReportPromptToReportBehavior)(reportDesigner1, Sub(behavior)
            ' ...
        End Sub)
    End Sub
End Class

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.

csharp
internal static class Program {
    [STAThread]
    static void Main() {
        //...
        // The Initialize() method forcibly initializes the behavior manager in .NET Framework apps.
        DevExpress.AIIntegration.WinForms.Reporting.BehaviorInitializer.Initialize();
        Application.Run(new Form1());
    }
}

Create Reports

Once the behavior is registered, the Report Wizard interface displays the new AI Prompt-to-Report option. Select this option to create the AI-generated report.

The AI-powered report generation works with two data source options:

No Data Source Option

If you select No Data Source , the “Enter Report Description” page appears. The Report Wizard interface includes a prompt input area with placeholder fields that guide users toward detailed prompts. Specify and configure a prompt and click Finish to see the result.

The following image illustrates the resulting report:

You can review the report layout and bind elements to data as needed.

Note

You can either adjust predefined prompts or write a new prompt from scratch. Review the Configure Report Prompt section for more information.

Add Data Source Option

If you select Add Data Source , the Wizard proceeds to the Select a Data Connection page to create a data connection.

After you have connected to a data source, the “Enter Report Description” page appears. The Report Wizard interface includes a prompt input area with placeholder fields that guide users toward detailed prompts. The “Data Source Structure” field list contains the resulting data source schema. You can add field names to a prompt to create a data-bound report.

The following image illustrates the data-bound report and its preview:

Note

You can either adjust predefined prompts or write a new prompt from scratch. Review the Configure Report Prompt section for more information.

Configure Report Prompt

General Tips

The output quality depends on the details you specify in the natural language description. Users should include detailed information about layout preferences, calculations, grouping requirements, and visualization types. Like other LLM implementations, the system has limitations and may need adjustments to meet your requirements.

You can specify Temperature to control the output randomness and use RetryAttemptCount to increase the number of attempts to fix report layout errors that may appear in the LLM response.

Configure Predefined Prompts

Built-in prompt suggestions show useful examples. You can review these to create your own prompts. For example, check the “Prompt Template” entry - a basic template you can customize. You can set up page layout, styles, fields, and functions. Other templates cover common report types, like invoices.

Note that prompt changes made in the Report Wizard do not persist.

To make permanent changes to built-in prompts, access the PredefinedPrompts collection in the BehaviorManager at design time. Modify prompt “Text” and “Title”. You can also add custom prompts to the collection at design time or in code.

Add a New Prompt

The following code snippet obtains built-in DevExpress prompts from AIReportPromptCollection, creates a custom prompt (an AIReportPrompt object), and adds this prompt to the collection. The collection is assigned to the ReportPromptToReportBehaviorProperties.PredefinedPrompts property.

csharp
using DevExpress.AIIntegration.WinForms.Reporting;
// ...
public partial class Form1 : Form {
    public Form1() {
        behaviorManager1.Attach<ReportPromptToReportBehavior>(reportDesigner1, behavior => {
            // Obtain built-in DevExpress prompts from the collection.
            var collection = AIReportPromptCollection.GetDefaultReportPrompts();
            // Create a custom prompt.
            AIReportPrompt customPrompt = new AIReportPrompt();
            customPrompt.Title = "Custom Prompt";
            customPrompt.Text = Prompts.CustomAIReportPrompt;
            // Add this prompt to the collection.
            collection.Add(customPrompt);
            // Display Prompts in the Report Wizard.
            behavior.Properties.PredefinedPrompts = collection;
        });
    }
    public static class Prompts {
        public const string CustomAIReportPrompt = "Create Sample Report:\r\n \r\nPage Setup:\r\n- Paper Size: A4\r\n- Report Margins:\r\n - Top & Bottom: 40\r\n - Left & Right: 60\r\n\r\nReport Header:\r\n- Title: Sample Report\r\n- Alignment: Center\r\n- Font: Comic Sans MS, 12pt, Bold\r\n\r\nCreate a horizontal table with the four column headers that correspond to fields in the bound data source.\r\n\r\nFont for column headers: Comic Sans MS, 12pt, Bold\r\n \r\nDetail Section:\r\nBind data cells to the fields corresponding to the column headers defined in the Group Header\r\nFont for data cells: Comic Sans MS, 12pt, Bold\r\n \r\nSummary Section:\r\nInclude calculated values for bound fields.\r\nSummary type: [Sum]\r\nFont for summary values: Comic Sans MS, 12pt, Bold";
    // ...
    }
}
vb
Imports DevExpress.AIIntegration.WinForms.Reporting
' ...
Partial Public Class Form1
    Inherits Form

    Public Sub New()
        behaviorManager1.Attach(Of ReportPromptToReportBehavior)(reportDesigner1, Sub(behavior)
            ' Obtain built-in DevExpress prompts from the collection.
            Dim collection = AIReportPromptCollection.GetDefaultReportPrompts()
            ' Create a custom prompt.
            Dim customPrompt As New AIReportPrompt()
            customPrompt.Title = "Custom Prompt"
            customPrompt.Text = Prompts.CustomAIReportPrompt
            ' Add this prompt to the collection.
            collection.Add(customPrompt)
            ' Display Prompts in the Report Wizard.
            behavior.Properties.PredefinedPrompts = collection
        End Sub)
    End Sub
    Public Module Prompts
        Public Const CustomAIReportPrompt As String = "Create Sample Report:" & vbCrLf & " " & vbCrLf & "Page Setup:" & vbCrLf & "- Paper Size: A4" & vbCrLf & "- Report Margins:" & vbCrLf & " - Top & Bottom: 40" & vbCrLf & " - Left & Right: 60" & vbCrLf & vbCrLf & "Report Header:" & vbCrLf & "- Title: Sample Report" & vbCrLf & "- Alignment: Center" & vbCrLf & "- Font: Comic Sans MS, 12pt, Bold" & vbCrLf & vbCrLf & "Create a horizontal table with the four column headers that correspond to fields in the bound data source." & vbCrLf & vbCrLf & "Font for column headers: Comic Sans MS, 12pt, Bold" & vbCrLf & " " & vbCrLf & "Detail Section:" & vbCrLf & "Bind data cells to the fields corresponding to the column headers defined in the Group Header" & vbCrLf & "Font for data cells: Comic Sans MS, 12pt, Bold" & vbCrLf & " " & vbCrLf & "Summary Section:" & vbCrLf & "Include calculated values for bound fields." & vbCrLf & "Summary type: [Sum]" & vbCrLf & "Font for summary values: Comic Sans MS, 12pt, Bold"
    ' ...
    End Module
End Class

At design time, you can add this prompt using the Collection Editor of PredefinedPrompts:

After you add a custom prompt to the collection, it appears in the Report Wizard:

The following image illustrates the result:

More Examples

The following example creates and registers the AI-powered Report Wizard manually. This approach allows you to incorporate AI options within the Wizard and customize associated pages as needs dictate.

View Example: WinForms Reporting – Add AI-powered Options to the DevExpress Report Wizard and Customize the First Page