Class AutoAppend
The AutoAppend class provides choice-list auto-append capabilities for editable combo boxes, etc.
Inheritance
Implements
Inherited Members
Namespace: Syncfusion.Windows.Forms.Tools
Assembly: Syncfusion.Shared.Base.dll
Syntax
public class AutoAppend : IDisposable
Remarks
Often editable combo boxes in your applications can benefit from reusing previously user supplied entries in their choice-list, as in IE's address bar combo box and in the "Find" combo box in VS.NET.
The AutoAppend class will easily enable this functionality in an associated combo box. In fact, this class is more abstract in that it can take any control and an IList reference and enable "AutoAppend" logic on them as described below.
Associate your control with this class through the AutoAppendInfo structure. The AutoAppendInfo structure will let you associate a control with an IList reference and a Category string to an AutoAppend instance.
Once you set up this association, the AutoAppend instance listens to the Validated event thrown by the control and inserts the new entry on top of the supplied IList or if already in the list, moves the entry to top of the list. When the control gets disposed, it persists these entries in the registry in a key based on the corresponding Category string. The next time the control is created and associated, the AutoAppend instance will pick up the persisted information corresponding to the Category and apply that information to the IList instance.
Persistance is done in the registry under the HKLU key making the entries specific to the user and global to the machine (usable across applications). Due to the previous behavior, the very first instantiation of the above control will set the control's text and the IList to be empty.
You can make any number of associations with one AutoAppend instance.
Examples
This is how you would associate a combo box with an instance of the AutoAppend class:
this.autoAppend = new AutoAppend();
this.autoAppend.SetAutoAppend(this.comboBox1, new AutoAppendInfo(true, "HttpAddress", this.comboBox1.Items, 30));
// To disassociate call this:
this.autoAppend.SetAutoAppend(this.comboBox1, new AutoAppendInfo(false, String.Empty, null, 30));
Constructors
AutoAppend()
Creates a new instance of the AutoAppend class.
Declaration
public AutoAppend()
Methods
Dispose()
Releases all setup associations.
Declaration
public void Dispose()
Remarks
This will also persist the exisiting information before releasing the associations.
Dispose(Boolean)
Override this to release the unmanaged resources used by the control and optionally releases the managed resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | True to release both managed and unmanaged resources; False to release only unmanaged resources. |
Finalize()
This member overrides Object.Finalize.
Declaration
protected void Finalize()
GetAutoAppend(Control)
Returns the AutoAppendInfo associated with a control.
Declaration
public virtual AutoAppendInfo GetAutoAppend(Control control)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.Control | control | The control whose AutoAppend info is required. |
Returns
Type | Description |
---|---|
AutoAppendInfo | The corresponding AutoAppendInfo value. If this control is not associated yet, then an AutoAppendInfo with its AutoAppend value set to False will be returned. |
InsertOrMoveToTop(Control, String)
Forces an entry into the control's AutoAppend list.
Declaration
public void InsertOrMoveToTop(Control control, string item)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.Control | control | The control whose AutoAppend list is to be updated. |
System.String | item | The value that is to be appended to the list. |
Remarks
The AutoAppend instance automatically inserts entries into the list when the user enters a new value and leaves the control (when Validated will be fired). However, you might want new entries to be added when, for example, the user hits the Enter key. You do so by calling this method with the new value which will insert the new value into the list.
SetAutoAppend(Control, AutoAppendInfo)
Associates a control with this instance by providing its AutoAppendInfo.
Declaration
public virtual void SetAutoAppend(Control control, AutoAppendInfo autoAppendInfo)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.Control | control | The control in which to AutoAppend. |
AutoAppendInfo | autoAppendInfo | The AutoAppendInfo. |
Remarks
Calling this will enable AutoAppend behavior in the control. Take a look at the AutoAppend class reference for detailed information on this behavior.
To disassociate a control from the AutoAppend instance, call this method with the AutoAppendInfo's AutoAppend value set to False.