Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
AutoComplete - Infralogistics
Message
General information
Forum:
ASP.NET
Category:
Forms
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01242788
Message ID:
01242821
Views:
24
Gregorio,

I've implemented my own AutoComplete ComboBox:
	public class MyComboBoxAutoComplete : MyComboBox
	{
		#region Declarations

		private bool InEditMode = true;

		#endregion

		#region Constructor

		public MyComboBoxAutoComplete()
		{
			this.DropDownStyle = ComboBoxStyle.DropDown;
			this.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
			this.AutoCompleteSource = AutoCompleteSource.ListItems;
		}
		#endregion

		#region Properties

		[DefaultValue(typeof(ComboBoxStyle), "DropDown")]
		public new ComboBoxStyle DropDownStyle
		{
			get { return base.DropDownStyle; }
			set { base.DropDownStyle = value; }
		}
		[DefaultValue(typeof(AutoCompleteMode), "SuggestAppend")]
		public new AutoCompleteMode AutoCompleteMode
		{
			get { return base.AutoCompleteMode; }
			set { base.AutoCompleteMode = value; }
		}
		[DefaultValue(typeof(AutoCompleteSource), "ListItems")]
		public new AutoCompleteSource AutoCompleteSource
		{
			get { return base.AutoCompleteSource; }
			set { base.AutoCompleteSource = value; }
		}

		#endregion

		#region Events

		protected override void OnBindingContextChanged(EventArgs e)
		{
			this.DropDownStyle = ComboBoxStyle.DropDown;
			base.OnBindingContextChanged(e);
		}
		protected override void OnValidating(CancelEventArgs e)
		{
			int index = this.FindStringExact(this.Text);
			if (index >= 0) 
				base.OnValidating(e);
			else
			if (this.Text.Trim() == "")
			{
				// do nothing
			}
			else
				e.Cancel = true;
		}
		protected override void OnKeyDown(KeyEventArgs e)
		{
			this.InEditMode = (e.KeyCode != Keys.Back && e.KeyCode != Keys.Delete);
			base.OnKeyDown(e);
		}
		protected override void OnTextChanged(EventArgs e)
		{
			if (this.InEditMode)
			{
				int index = this.FindString(this.Text);
				if (index < 0 && this.Text.Trim() != "")
				{
					this.InEditMode = false;
					this.Text = this.Text.Substring(0, this.Text.Length - 1);
					this.InEditMode = true;
					this.Select(this.Text.Length, this.Text.Length);
				}
			}

			base.OnTextChanged(e);
		}

		#endregion
	}
That might help get you started with your own.

~~Bonnie

>Hi All!
>
>I want to know if somebody has implemented Autocomplete using the ComboBox control of Infralogistic. If so, bring me some code that I can see the implementation.
>
>Thank in advance.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform