Skip to main content
All docs
V26.1
  • Prompt to Report Behavior in the WinForms Report Designer

    • 7 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).

    Prerequisites

    .NET8+ or NET Framework v4.7.2+

    Install NuGet Packages

    Install the following NuGet packages:

    See the following help topic for information on how to install DevExpress NuGet packages: Install DevExpress Products

    Register AI Client

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

    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-5.2.
        [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());
        }
    }
    

    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.

      Register AI-powered Behaviors

    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:

      Add Report Prompt-to-Report Behavior

      The following settings are available:

      • FixLayoutErrors

        Specifies whether the designer attempts to fix the report layout in case of overlapping report controls.

      • RetryAttemptCount

        Defines the number of attempts to fix report layout errors that may appear in the LLM response. The default value is 3.

      • Predefined Prompts

        Specifies predefined prompts that can be used for the report creation.

      • Temperature

        Controls output randomness. Lower temperatures (values between 0 and 0.5) yield more predictable and focused outputs, while higher temperatures (values between 0.5 and 1) produce more diverse and creative responses. The default value is 0.

      • Target

        Attaches behaviors to DevExpress controls.

    Create and Configure a Behavior Object in Code

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

    using DevExpress.AIIntegration.WinForms.Reporting;
    // ...
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
            behaviorManager1.Attach<ReportPromptToReportBehavior>(reportDesigner1, behavior => {
               // ...
            });
        }
    }
    

    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.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.

    AI Prompt-to-Report option in Report Wizard

    Select Data Source Option

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

    Select Data Source Option for AI Report

    No Data Source
    Creates a complete report structure based only on the user’s natural language description.
    Add Data Source
    Allows users to create a report data source in the first step, displays the data source structure in the Report Wizard, and automatically includes this metadata in the LLM prompt. Users can reference available data source fields when they describe data-bound report elements.

    Enter Report Prompt

    Choose a predefined prompt or enter your own prompt. Then click Next.

    Enter Report Prompt in Report Wizard

    Note

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

    On the next page, the Wizard analyzes the specified prompt and builds the report:

    AI Report Building in Progress

    If input is incomplete or ambiguous, the system may request additional information about the report structure, such as:

    • “What should the report title be?”
    • “Would you like to introduce customer address details in the report: yes/no?”
    • “Please specify the page size and orientation for this report. For example, A4, portrait, letter landscape, or custom dimensions.”

    AI Prompt-to-Report requests additional report details

    Generation resumes automatically after the user supplies an answer.

    Configure Report Prompt

    General Tips

    Report generation uses a structured agentic workflow composed of specialized agents. Each agent handles a distinct stage of the pipeline, from intent clarification and input validation to layout planning and output verification.

    Output accuracy depends on the level of detail in the natural-language description. The more detail the user provides about layout preferences, calculations, grouping requirements, and visualization types, the fewer assumptions the model needs to make.

    Users can also describe the report intent in plain language without specifying the exact report structure. In this case, the model may request additional information and adapt the report based on the user’s input to generate a valid layout.

    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.

    Use Predefined Prompts

    Built-in prompt suggestions show useful examples. You can review these or create your own prompts.

    Report Wizard - Predefined Prompts

    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.

    Prompts collection in BehaviorManager

    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.

    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 = "Custom Prompt Text";
                // Add this prompt to the collection.
                collection.Add(customPrompt);
                // Display Prompts in the Report Wizard.
                behavior.Properties.PredefinedPrompts = collection;
            });
        }
    }
    

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

    Custom prompt in collection editor

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

    Custom prompt in wizard

    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