> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/fr/apps/components/inputs/automcomplete.md).

# Saisie automatique

La saisie automatique est un champ de texte ordinaire amélioré par un panneau d'options suggérées.

## Liste statique d'options

Crée une saisie automatique de base avec une liste statique d'options.

```powershell
New-UDAutocomplete -Options @('Test', 'Test2', 'Test3', 'Test4')
```

## Liste dynamique d'options

Lorsque du texte est saisi, il peut être filtré à l'aide de `OnLoadOptions`. `$Body` contiendra le texte actuellement saisi.

Cet exemple filtre le tableau avec `Where-Object`.

```powershell
New-UDAutocomplete -OnLoadOptions { 
    @('Test', 'Test2', 'Test3', 'Test4') | Where-Object { $_ -like "*$Body*" } | ConvertTo-Json
}
```

## OnChange

`$Body` contient l'élément actuellement sélectionné. L'événement OnChange se déclenche lorsque l'utilisateur sélectionne un ou plusieurs éléments.

```powershell
New-UDAutocomplete -OnLoadOptions { 
    @('Test', 'Test2', 'Test3', 'Test4') | Where-Object { $_ -like "*$Body*" } | ConvertTo-Json
} -OnChange {
    Show-UDToast $Body 
}
```

## Icône

![](/files/8XwI1CWfZM1WS5U9Ezvg)

Vous pouvez placer une icône avant la saisie automatique en utilisant le paramètre `-Icon`.

```powershell
New-UDAutocomplete -Options @("Test", "No", "Yes") -Icon (New-UDIcon -Icon 'Users') 
```

## OnEnter

OnEnter se déclenche lorsque l'utilisateur appuie sur la touche Entrée dans la saisie automatique.

```powershell
New-UDAutocomplete -Options @("Test", "No", "Yes") -onEnter {
    Show-UDToast ((Get-UDElement -Id 'ac').value)
} -Id 'ac'
```

## Options

Vous pouvez utiliser `New-UDAutoCompleteOption` pour spécifier des noms et des valeurs.

```powershell
New-UDAutocomplete -Options @(
    New-UDAutoCompleteOption -Name 'Adam D' -Value '1'
    New-UDAutoCompleteOption -Name 'Sarah F' -Value '2'
    New-UDAutoCompleteOption -Name 'Tom S' -Value '3'
)
```

## API

* [New-UDAutocomplete](https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDAutocomplete.txt)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.devolutions.net/powershell-universal/fr/apps/components/inputs/automcomplete.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
