--- title: "How to: Enable AutoComplete in ToolStrip Controls" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "AutoComplete [Windows Forms], examples" - "toolbars [Windows Forms], AutoComplete" - "examples [Windows Forms], toolbars" - "AutoComplete [Windows Forms], enabling in toolbars" - "ToolStripComboBox class [Windows Forms], examples" - "ToolStrip control [Windows Forms], AutoComplete" ms.assetid: fd66d085-1af1-45d4-930a-cde944da2e16 --- # How to: Enable AutoComplete in ToolStrip Controls in Windows Forms The following procedure combines a with a that can be dropped down to show a list of items, such as recently visited Web sites. If the user types a character that matches the first character of one of the items in the list, the item is immediately displayed. > [!NOTE] > Automatic completion works with `ToolStrip` controls in the same way that it works with traditional controls such as and . ### To enable AutoComplete in a ToolStrip control 1. Create a control and add items to it. ```vb ToolStrip1 = New System.Windows.Forms.ToolStrip ToolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem()_ {ToolStripLabel1, ToolStripComboBox1}) ``` ```csharp toolStrip1 = new System.Windows.Forms.ToolStrip(); toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {toolStripLabel1, toolStripComboBox1}); ``` 2. Set the property of the label and the combo box to so that the list is always available regardless of the form's size. ```vb ToolStripLabel1.Overflow = _ System.Windows.Forms.ToolStripItemOverflow.Never ToolStripComboBox1.Overflow = _ System.Windows.Forms.ToolStripItemOverflow.Never ``` ```csharp toolStripLabel1.Overflow = _ System.Windows.Forms.ToolStripItemOverflow.Never toolStripComboBox1.Overflow = System.Windows.Forms.ToolStripItemOverflow.Never ``` 3. Add words to the Items collection of the control. ```vb ToolStripComboBox1.Items.AddRange(New Object() {"First Item", _ "Second Item", "Third Item"}) ``` ```csharp toolStripComboBox1.Items.AddRange(new object[] {"First item", "Second item", "Third item"}); ``` 4. Set the property of the combo box to . ```vb ToolStripComboBox1.AutoCompleteMode = _ System.Windows.Forms.AutoCompleteMode.Append ``` ```csharp toolStripComboBox1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Append; ``` 5. Set the property of the combo box to . ```vb ToolStripComboBox1.AutoCompleteSource = _ System.Windows.Forms.AutoCompleteSource.ListItems ``` ```csharp toolStripComboBox1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; ``` ## See also - - - - - - [ToolStrip Control Overview](toolstrip-control-overview-windows-forms.md) - [ToolStrip Control Architecture](toolstrip-control-architecture.md) - [ToolStrip Technology Summary](toolstrip-technology-summary.md)