Back to Devexpress

SmartAutoCompleteBehavior Class

windowsforms-devexpress-dot-aiintegration-dot-winforms-5025f91b.md

latest3.8 KB
Original Source

SmartAutoCompleteBehavior Class

Intelligently predicts and suggests words or phrases based on the user’s current input.

Namespace : DevExpress.AIIntegration.WinForms

Assembly : DevExpress.AIIntegration.WinForms.v25.2.dll

NuGet Package : DevExpress.AIIntegration.WinForms

Declaration

csharp
public sealed class SmartAutoCompleteBehavior :
    BehaviorWithEvents<ITextAutocompleteBehavior>
vb
Public NotInheritable Class SmartAutoCompleteBehavior
    Inherits BehaviorWithEvents(Of ITextAutocompleteBehavior)

Remarks

MemoExEdit seamlessly integrates 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.

csharp
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;
                behavior.Properties.Events.OperationFailed += Events_OperationFailed;
            });
        }
    }

    void Events_OperationFailed(object sender, AIOperationFailedEventArgs e) {
        // Handle the operation failure
    }
}
vb
Imports DevExpress.AIIntegration.WinForms

Namespace SmartAutoCompleteDemo
    Partial Public Class Form1
        Inherits DevExpress.XtraEditors.XtraForm

        Public Sub New()
            InitializeComponent()
            behaviorManager1.Attach(Of SmartAutoCompleteBehavior)(memoEdit1, Sub(behavior)
                behavior.Properties.TypingPauseDelay = 200
                AddHandler behavior.Properties.Events.OperationFailed, AddressOf Events_OperationFailed
            End Sub)
        End Sub

        Private Sub Events_OperationFailed(sender As Object, e As AIOperationFailedEventArgs)
            ' Handle the operation failure
        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.

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

Read the following help topic for additional information and examples: Smart Autocomplete.

Inheritance

Object DevExpress.Utils.MVVM.BehaviorBase DevExpress.Utils.Behaviors.Behavior DevExpress.Utils.Behaviors.Behavior<DevExpress.AIIntegration.WinForms.ITextAutocompleteBehavior> DevExpress.Utils.Behaviors.BehaviorWithEvents<DevExpress.AIIntegration.WinForms.ITextAutocompleteBehavior> SmartAutoCompleteBehavior

See Also

SmartAutoCompleteBehavior Members

DevExpress.AIIntegration.WinForms Namespace