|
1 | 1 | # Winforms-AutoComplete-Examples |
2 | | -The WinForms Autocomplete component allows users to enable autocompletion functionality for any edit control. Multiple columns with a header in the autocomplete pop-up provide information for each matching entry. Its rich, built-in feature set includes different autocompletion modes such as suggest and append, appearance customization, and more. For more details please refer [What is winforms AutoComplete](https://www.syncfusion.com/kb/1086/what-is-the-autocomplete-control). |
| 2 | +## Overview |
| 3 | +The WinForms AutoComplete component allows users to enable autocomplete functionality to edit controls. It supports multi-column suggestions with headers, multiple modes (Suggest, Append, SuggestAppend), and rich appearance customization. See What is WinForms AutoComplete for details: https://www.syncfusion.com/kb/1086/what-is-the-autocomplete-control |
3 | 4 |
|
4 | 5 | ## AutoComplete Modes |
5 | | -* Suggest: Displays suggestion in drop-down list. |
6 | | - |
| 6 | +* Suggest: Shows suggestions in a drop-down list. |
| 7 | + |
7 | 8 |  |
8 | | - |
9 | | -* Append: Appends the first suggestion to text. |
10 | | - |
| 9 | +* Append: Appends the best match to the typed text. |
| 10 | + |
11 | 11 |  |
12 | | - |
13 | | -* SuggestAppend: Performs both the above ways. |
14 | | - |
| 12 | +* SuggestAppend: Combines Suggest and Append. |
| 13 | + |
15 | 14 |  |
16 | 15 |
|
17 | | -## DataSource |
18 | | -Sets the Datasource to the Autocomplete component. The AutoComplete component automatically picks the "History Data List" mode or "Data source" mode based on the values set for the DataSource property. When the datasource property is set to NULL (default value is NULL), the component defaults to History Data List mode. It is to be remembered that the properties CategoryName, AutoAddItem, and AutoSerialize have to be set appropriately for the History Data List mode to work properly. |
| 16 | +## DataSource for AutoComplete |
| 17 | +Datasource for AutoComplete operates in one of two ways, chosen by the DataSource property: |
| 18 | +- History Data List mode: When DataSource is null (default), the control records and uses user-entered items. Set CategoryName, AutoAddItem, and AutoSerialize appropriately for this mode. |
| 19 | +- Data source mode: When DataSource is set, items come from your bound list. |
19 | 20 |
|
20 | 21 | ## Override Combo |
21 | | -If MS ComboBox is used as editor control, the Combobox dropdown can be suppressed and overridden by the AutoComplete component using the OverrideCombo property. |
| 22 | +When using a standard Windows Forms ComboBox as the editor, you can suppress the ComboBox’s own drop-down and use AutoComplete’s suggestion UI via the OverrideCombo property. |
22 | 23 |
|
23 | 24 |  |
24 | 25 |
|
25 | 26 | ## Persistence |
26 | | -The history list of AutoComplete component can be saved in the following formats: |
27 | | - |
28 | | -* Binary Format |
29 | | -* XML Format |
30 | | -* IsolatedStorage medium |
31 | | -* MemoryStream |
32 | | -* PersistState property |
| 27 | +The AutoComplete history list can be persisted in the following formats: |
33 | 28 |
|
34 | | -The AutoComplete component has a fully built-in serialization feature that provides automatic serialization for the AutoComplete’s history list. The serialization mechanism is implemented using the standardized Syncfusion.Windows.Forms.AppStateSerializer component that acts as a central coordinator for all the Essential tools components and provides options to read or write to different media such as the default isolated storage, XML file, XML stream, binary file, binary stream, and the Windows Registry. |
35 | | - |
36 | | -# Integration with RichTextBox control |
| 29 | +- Binary file/stream |
| 30 | +- XML file/stream |
| 31 | +- Isolated storage |
| 32 | +- Windows Registry |
37 | 33 |
|
38 | | -The auto-complete functionality can be added to the RichTextBox control. The following steps are used to integrate the RichTextBox with the AutoComplete component: |
| 34 | +You control this via the PersistState property and AppStateSerializer settings. Note: The serializer type is Syncfusion.Windows.Forms.AppStateSerializer. |
39 | 35 |
|
40 | | -1. Implement the `IEditControlsEmbed` interface in a CustomRichTextBox class that enables the AutoComplete functionality for the RichTextBox control. |
| 36 | +## Integration with RichTextBox control |
| 37 | +You can enable AutoComplete on a RichTextBox by implementing IEditControlsEmbed and calling SetAutoComplete. |
41 | 38 |
|
42 | | -## C# |
| 39 | +Step 1: Implement `IEditControlsEmbed` |
| 40 | +```C# |
| 41 | + using System.Windows.Forms; |
| 42 | + using Syncfusion.Windows.Forms.Tools; |
43 | 43 |
|
44 | | - public class CustomRichTextBox : System.Windows.Forms.RichTextBox, IEditControlsEmbed |
45 | | - |
46 | | - { |
| 44 | + public class CustomRichTextBox : RichTextBox, IEditControlsEmbed |
| 45 | + { |
47 | 46 | // Returns the active RichTextBox control. |
48 | 47 | public Control GetActiveEditControl(IEditControlsEmbedListener listener) |
49 | 48 | { |
50 | 49 | return (Control)this; |
51 | 50 | } |
52 | 51 | } |
53 | | - |
54 | | -2. Create an instance for the CustomRichTextBox class and the AutoComplete component. Then, use the [SetAutoComplete](https://help.syncfusion.com/cr/windowsforms/Syncfusion.Windows.Forms.Tools.AutoComplete.html#Syncfusion_Windows_Forms_Tools_AutoComplete_SetAutoComplete_System_Windows_Forms_Control_Syncfusion_Windows_Forms_Tools_AutoCompleteModes_) method of AutoComplete component to enable auto-complete support for the RichTextBox control. |
55 | | - |
56 | | -## C# |
57 | | - |
58 | | - Syncfusion.Windows.Forms.Tools.AutoComplete autoComplete1= new Syncfusion.Windows.Forms.Tools.AutoComplete(); |
59 | | - CustomRichTextBox richTextBox1= new CustomRichTextBox(); |
60 | | - autoComplete1.SetAutoComplete(richTextBox1, Syncfusion.Windows.Forms.Tools.AutoCompleteModes.AutoSuggest); |
61 | | - |
| 52 | +``` |
| 53 | +Step 2: Attach AutoComplete |
| 54 | +```C# |
| 55 | + var autoComplete = new AutoComplete(); |
| 56 | + var richTextBox = new CustomRichTextBox(); |
| 57 | + autoComplete.SetAutoComplete(richTextBox, AutoCompleteModes.AutoSuggest); |
| 58 | +``` |
62 | 59 |  |
0 commit comments