TextBox.AutoCompleteMode Proprietà
Definizione
public:
property System::Windows::Forms::AutoCompleteMode AutoCompleteMode { System::Windows::Forms::AutoCompleteMode get(); void set(System::Windows::Forms::AutoCompleteMode value); };
[System.ComponentModel.Browsable(true)]
public System.Windows.Forms.AutoCompleteMode AutoCompleteMode { get; set; }
public System.Windows.Forms.AutoCompleteMode AutoCompleteMode { get; set; }
[<System.ComponentModel.Browsable(true)>]
member this.AutoCompleteMode : System.Windows.Forms.AutoCompleteMode with get, set
member this.AutoCompleteMode : System.Windows.Forms.AutoCompleteMode with get, set
Public Property AutoCompleteMode As AutoCompleteMode
Valore della proprietà
Uno dei valori di AutoCompleteMode.One of the values of AutoCompleteMode. Di seguito vengono illustrati i valori.The following are the values.
Append
Aggiunge la parte restante della stringa candidata più probabile ai caratteri esistenti ed evidenzia i caratteri aggiunti.Appends the remainder of the most likely candidate string to the existing characters, highlighting the appended characters.
Suggest
Visualizza l'elenco a discesa ausiliario associato al controllo di modifica.Displays the auxiliary drop-down list associated with the edit control. Questo elenco viene compilato con una o più stringhe di completamento suggerite.This drop-down is populated with one or more suggested completion strings.
SuggestAppend
Accoda entrambe le opzioni Suggest
e Append
.Appends both Suggest
and Append
options.
None
Disabilita il completamento automatico.Disables automatic completion. Questo è il valore predefinito.This is the default.
- Attributi
Eccezioni
Il valore specificato non è uno dei valori dell'oggetto AutoCompleteMode.The specified value is not one of the values of AutoCompleteMode.
Esempio
Nell'esempio di codice riportato di seguito viene illustrato come utilizzare una raccolta come origine personalizzata di completamento automatico per un TextBox controllo.The following code example demonstrates how to use a collection as the auto-complete custom source for a TextBox control. In questo esempio vengono eseguite le operazioni seguenti:This example does the following:
Usa la AutoCompleteSource proprietà per consentire al TextBox controllo di accettare un'origine personalizzata per il comportamento di completamento automatico.Uses the AutoCompleteSource property to enable the TextBox control to accept a custom source for its auto-complete behavior.
Usa la AutoCompleteCustomSource proprietà per impostare l'elenco personalizzato di valori.Uses the AutoCompleteCustomSource property to set the custom list of values.
Usa la AutoCompleteMode proprietà per impostare il modo in cui vengono visualizzati i candidati con completamento automatico.Uses the AutoCompleteMode property to set how the auto-complete candidates are displayed.
private void Form1_Load(object sender, EventArgs e)
{
// Create the list to use as the custom source.
var source = new AutoCompleteStringCollection();
source.AddRange(new string[]
{
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
});
// Create and initialize the text box.
var textBox = new TextBox
{
AutoCompleteCustomSource = source,
AutoCompleteMode =
AutoCompleteMode.SuggestAppend,
AutoCompleteSource =
AutoCompleteSource.CustomSource,
Location = new Point(20, 20),
Width = ClientRectangle.Width - 40,
Visible = true
};
// Add the text box to the form.
Controls.Add(textBox);
}
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
' Create the list to use as the custom source.
Dim MySource As New AutoCompleteStringCollection()
MySource.AddRange(New String() _
{ _
"January", _
"February", _
"March", _
"April", _
"May", _
"June", _
"July", _
"August", _
"September", _
"October", _
"November", _
"December" _
})
' Create and initialize the text box.
Dim MyTextBox As New TextBox()
With MyTextBox
.AutoCompleteCustomSource = MySource
.AutoCompleteMode = AutoCompleteMode.SuggestAppend
.AutoCompleteSource = AutoCompleteSource.CustomSource
.Location = New Point(20, 20)
.Width = Me.ClientRectangle.Width - 40
.Visible = True
End With
' Add the text box to the form.
Me.Controls.Add(MyTextBox)
End Sub
Commenti
Utilizzare le AutoCompleteCustomSource AutoCompleteMode proprietà, e AutoCompleteSource per creare un oggetto TextBox che completa automaticamente le stringhe di input confrontando il prefisso immesso ai prefissi di tutte le stringhe in un'origine gestita.Use the AutoCompleteCustomSource, AutoCompleteMode, and AutoCompleteSource properties to create a TextBox that automatically completes input strings by comparing the prefix being entered to the prefixes of all strings in a maintained source. Questa operazione è utile per i TextBox controlli in cui gli URL, gli indirizzi, i nomi file o i comandi verranno immessi di frequente.This is useful for TextBox controls in which URLs, addresses, file names, or commands will be frequently entered.
L'uso della AutoCompleteCustomSource proprietà è facoltativo, ma è necessario impostare la AutoCompleteSource proprietà su per CustomSource
poter usare AutoCompleteCustomSource .The use of the AutoCompleteCustomSource property is optional, but you must set the AutoCompleteSource property to CustomSource
in order to use AutoCompleteCustomSource.
È necessario usare AutoCompleteMode insieme le AutoCompleteSource proprietà e.You must use the AutoCompleteMode and AutoCompleteSource properties together.
Nota
Il sistema operativo potrebbe limitare il numero di stringhe personalizzate che possono essere visualizzate contemporaneamente.The operating system might limit the number of custom strings that it can display at once.