Loading...
Loading...
Guides implementation of the Syncfusion WinForms AutoComplete control for text input with auto-suggestion functionality. Use when users want to add autocomplete textboxes, implement auto-suggestion features, create search boxes with suggestions, enable URL/email autocomplete, or build type-ahead search functionality in Windows desktop applications. Covers data binding, customization, filtering, multi-column dropdowns, events, and all AutoComplete-specific features.
npx skill4agent add syncfusion/winforms-ui-components-skills syncfusion-winforms-autocompleteInstall-Package Syncfusion.Tools.WindowsSyncfusion.Tools.Windows.dllSyncfusion.Shared.Base.dllusing System;
using System.Windows.Forms;
using Syncfusion.Windows.Forms.Tools;
namespace AutoCompleteDemo
{
public partial class Form1 : Form
{
private AutoComplete autoComplete1;
public Form1()
{
InitializeComponent();
// Create AutoComplete control
autoComplete1 = new AutoComplete();
autoComplete1.Location = new System.Drawing.Point(20, 20);
autoComplete1.Size = new System.Drawing.Size(200, 20);
autoComplete1.ParentForm = this;
// Add data source
autoComplete1.DataSource = new string[]
{
"Australia",
"Austria",
"Brazil",
"Canada",
"China"
};
// Add to form
this.Controls.Add(autoComplete1);
}
}
}AutoCompleteParentFormDataSourceParentFormAutoComplete autoComplete1 = new AutoComplete();
autoComplete1.Location = new System.Drawing.Point(20, 20);
autoComplete1.Size = new System.Drawing.Size(200, 20);
autoComplete1.ParentForm = this;
// Add string data
autoComplete1.DataSource = new string[]
{
"John", "Jane", "Bob", "Alice", "Charlie"
};
this.Controls.Add(autoComplete1);AutoComplete autoComplete1 = new AutoComplete();
autoComplete1.ParentForm = this;
// Create DataTable
DataTable dt = new DataTable();
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Email", typeof(string));
dt.Rows.Add("John Doe", "john@example.com");
dt.Rows.Add("Jane Smith", "jane@example.com");
autoComplete1.DataSource = dt;
autoComplete1.DisplayMember = "Name";
this.Controls.Add(autoComplete1);AutoComplete autoComplete1 = new AutoComplete();
autoComplete1.ParentForm = this;
autoComplete1.Style = AutoCompleteStyle.Default;
// Create DataTable with multiple columns
DataTable dt = new DataTable();
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Country", typeof(string));
dt.Columns.Add("City", typeof(string));
dt.Rows.Add("John Doe", "USA", "New York");
dt.Rows.Add("Jane Smith", "UK", "London");
dt.Rows.Add("Bob Johnson", "Canada", "Toronto");
autoComplete1.DataSource = dt;
// Configure columns
autoComplete1.Columns.Add(new AutoCompleteDataColumnInfo("Name", 100));
autoComplete1.Columns.Add(new AutoCompleteDataColumnInfo("Country", 80));
autoComplete1.Columns.Add(new AutoCompleteDataColumnInfo("City", 80));
this.Controls.Add(autoComplete1);AutoComplete autoComplete1 = new AutoComplete();
autoComplete1.ParentForm = this;
autoComplete1.DataSource = GetDataSource();
// Handle custom filtering
autoComplete1.AutoCompleteControl.ItemsListBox.DrawItem +=
new DrawItemEventHandler(ItemsListBox_DrawItem);
void ItemsListBox_DrawItem(object sender, DrawItemEventArgs e)
{
if (e.Index >= 0)
{
// Custom drawing logic
e.DrawBackground();
e.Graphics.DrawString(
autoComplete1.AutoCompleteControl.ItemsListBox.Items[e.Index].ToString(),
e.Font,
Brushes.Black,
e.Bounds);
e.DrawFocusRectangle();
}
}
this.Controls.Add(autoComplete1);AutoComplete autoComplete1 = new AutoComplete();
autoComplete1.ParentForm = this;
autoComplete1.Size = new System.Drawing.Size(300, 20);
// Common URLs
autoComplete1.DataSource = new string[]
{
"http://www.syncfusion.com",
"http://www.google.com",
"http://www.microsoft.com",
"http://www.github.com"
};
// Enable append mode for URL completion
autoComplete1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
this.Controls.Add(autoComplete1);| Property | Type | Default | Description |
|---|---|---|---|
| object | null | Data source for suggestions (array, DataTable, etc.) |
| Form | null | Parent form containing the control (required) |
| AutoCompleteMode | Suggest | Behavior mode: None, Suggest, Append, SuggestAppend |
| string | "" | Property name to display from data source |
| string | "" | Property name for internal value |
| AutoCompleteDataColumnInfoCollection | - | Column configuration for multi-column display |
| AutoCompleteStyle | Default | Visual style of the control |
| string | "" | Current text value |
| object | null | Currently selected value |
| CharacterCasing | Normal | Text casing: Normal, Upper, Lower |
| bool | false | Load suggestions on demand |
| AutoCompletePopup | - | Access to underlying popup control |
ParentFormAutoCompleteModeSuggestAppendSuggestAppendLoadOnDemandAutoCompleteValueChangedResetItems()DataSource = nullCharacterCasingautoComplete1.Style = AutoCompleteStyle.Office2016Colorful;ParentFormDataSourceAutoCompleteStyleColumnsLoadOnDemand