xtrareports-405566-ai-powered-functionality-desktop-reporting-preview-reports-with-ai-generated-test-data-win-forms-report-designer.md
Users can generate AI-powered test data to preview reports without connecting to a live data source directly within the WinForms Report Designer. Follow the instructions in this help topic to activate AI-generated Test Data in the Report Designer.
Once AI-generated Test Data is activated, the Report Designer displays the Test Data tab. Click it to preview the report with AI-generated test data. The Report Designer requests data from an LLM and populates the report with meaningful values for preview.
.NET8+ or NET Framework v4.7.2+
Install the following NuGet packages:
DevExpress.AIIntegration.WinForms.ReportingDevExpress.Win.Design (activates design-time features for DevExpress WinForms UI controls in .NET projects)See the following help topics for information on how to obtain the DevExpress NuGet Feed and install DevExpress NuGet packages:
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-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());
}
}
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.
Follow the steps below to attach a Report Test Data Source Behavior to the WinForms Report Designer at design time:
Drop the BehaviorManager component from the Toolbox onto a Form that contains the WinForms Report Designer.
Invoke the BehaviorManager‘s smart tag menu and click Edit Behaviors to open the Behavior Collection Editor.
Add a Report Test Data Source Behavior and specify its RowCount and Temperature settings.
Drop the BehaviorManager component from the Toolbox onto a Form that contains the WinForms Report Designer control. Use the following code to register a ReportTestDataSourceBehavior and attach it to the WinForms Report Designer (reportDesigner1):
using DevExpress.AIIntegration.WinForms.Reporting;
namespace DXAppReportsTestData {
public partial class XtraForm1 : DevExpress.XtraBars.Ribbon.RibbonForm {
public XtraForm2() {
InitializeComponent();
behaviorManager1.Attach<ReportTestDataSourceBehavior>(reportDesigner1, behavior => {
behavior.Properties.Temperature = 0.3f;
behavior.Properties.RowCount = 10;
});
reportDesigner1.OpenReport(new Report1());
}
}
}
Imports DevExpress.AIIntegration.WinForms.Reporting
Namespace DXAppReportsTestData
Partial Public Class XtraForm1
Inherits DevExpress.XtraBars.Ribbon.RibbonForm
Public Sub New()
InitializeComponent()
behaviorManager1.Attach(Of ReportTestDataSourceBehavior)(reportDesigner1,
Sub(behavior)
behavior.Properties.Temperature = 0.3F
behavior.Properties.RowCount = 10
End Sub)
reportDesigner1.OpenReport(New Report1())
End Sub
End Class
End Namespace
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());
}
}
See Also
Preview Reports with AI-generated Test Data (WPF Report Designer)
Preview Reports with AI-generated Test Data (Web Report Designer)
Preview Reports with AI-generated Test Data in Visual Studio Report Designer