TextBox.AutoCompleteCustomSource TextBox.AutoCompleteCustomSource TextBox.AutoCompleteCustomSource TextBox.AutoCompleteCustomSource Property

Definición

Obtiene o establece un elemento StringCollection personalizado que se usará cuando la propiedad AutoCompleteSource esté establecida en CustomSource.Gets or sets a custom StringCollection to use when the AutoCompleteSource property is set to CustomSource.

public:
 property System::Windows::Forms::AutoCompleteStringCollection ^ AutoCompleteCustomSource { System::Windows::Forms::AutoCompleteStringCollection ^ get(); void set(System::Windows::Forms::AutoCompleteStringCollection ^ value); };
[System.ComponentModel.Browsable(true)]
public System.Windows.Forms.AutoCompleteStringCollection AutoCompleteCustomSource { get; set; }
member this.AutoCompleteCustomSource : System.Windows.Forms.AutoCompleteStringCollection with get, set
Public Property AutoCompleteCustomSource As AutoCompleteStringCollection

Valor de propiedad

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar una colección como origen personalizado para Autocompletar un TextBox control.The following code example demonstrates how to use a collection as the auto-complete custom source for a TextBox control. En el ejemplo, se realizan las tareas siguientes:This example does the following:

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

Comentarios

Use la AutoCompleteCustomSource, AutoCompleteMode, y AutoCompleteSource propiedades para crear un TextBox que completa automáticamente las cadenas de entrada comparando el prefijo que se escribió para los prefijos de todas las cadenas de un origen de mantener.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. Esto es útil para TextBox controles en el que las direcciones URL, direcciones, los nombres de archivo o los comandos se escribirán frecuentemente.This is useful for TextBox controls in which URLs, addresses, file names, or commands will be frequently entered.

El uso de la AutoCompleteCustomSource propiedad es opcional, pero debe establecer el AutoCompleteSource propiedad CustomSource para poder usar AutoCompleteCustomSource.The use of the AutoCompleteCustomSource property is optional, but you must set the AutoCompleteSource property to CustomSource in order to use AutoCompleteCustomSource.

Debe usar el AutoCompleteMode y AutoCompleteSource propiedades juntas.You must use the AutoCompleteMode and AutoCompleteSource properties together.

Nota

El sistema operativo podría limitar el número de cadenas personalizadas que puede mostrar al mismo tiempo.The operating system might limit the number of custom strings that it can display at once.

Se aplica a

Consulte también: