Skip to main content
All docs
V24.2

Smart Autocomplete

  • 2 minutes to read

The AI-powered “Smart Autocomplete” feature intelligently predicts and suggests words or phrases based on the user’s current input.

Applies To

MemoEdit

How It Works

DevExpress UI controls seamlessly integrate Smart Autocomplete. When Smart Autocomplete is activated, as you type, the AI model analyzes the context of the text and makes relevant suggestions in real time. Press Tab or click the suggestion to append it to the text. Press the Esc key to hide the suggestion.

Smart Autocomplete - WinForms MemoEdit, DevExpress

Activate Smart Autocomplete

1. Install DevExpress NuGet Packages

  1. DevExpress.AIIntegration.WinForms
  2. DevExpress.Win.Design (enables design-time features for DevExpress UI controls)

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

2. Register 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 asChatClient = new Azure.AI.OpenAI.AzureOpenAIClient(new Uri(AzureOpenAIEndpoint),
            new System.ClientModel.ApiKeyCredential(AzureOpenAIKey))
            .AsChatClient("GPT4o");
        AIExtensionsContainerDesktop.Default.RegisterChatClient(asChatClient);
        Application.Run(new Form1());
    }
    static string AzureOpenAIEndpoint { get { return Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT"); } }
    static string AzureOpenAIKey { get { return Environment.GetEnvironmentVariable("AZURE_OPENAI_APIKEY"); } }
}

Tip

Read the following help topic for additional information: How to Register an AI Client.

3. Create and Configure Smart Autocomplete Behavior

  1. Drop the BehaviorManager component from the Toolbox onto a Form. The Form should contain the DevExpress MemoEdit.
  2. Add a SmartAutoCompleteBehavior, configure the TypingPauseDelay setting if needed, and attach the behavior to the MemoEdit. You can do this at design time or in code:

    using DevExpress.AIIntegration.WinForms;
    
    namespace SmartAutoCompleteDemo {
        public partial class Form1 : DevExpress.XtraEditors.XtraForm {
            public Form1() {
                InitializeComponent();
                behaviorManager1.Attach<SmartAutoCompleteBehavior>(memoEdit1, behavior => {
                    behavior.Properties.TypingPauseDelay = 200;
                });
            }
        }
    }
    
See Also