We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Autocomplete: Do not allow values not in the list

I''m using a buttonedit field and allowing autocomplete with append only enabled. My button displays a treeview that the user can select from or autocomplete types ahead the value''s in the tree. I only want to allow the user to type data that is in the list. Can this be accomplished with the tools defined? I''ve attached my project so you can understand what I''m after. Quicken_752.zip

2 Replies

DC DC June 8, 2004 09:13 AM

The ComboBoxAutoComplete looks like it might work. However, I don''t want to display the concatenated text (see attachment in my previous post). Instead I want to display a tree view. There is an OverrideCombo property that I can set but it doesn''t seem to do anything and there''s no documentation. Any help would be much appreciated.


DJ Davis Jebaraj Syncfusion Team June 8, 2004 12:54 PM

Hi, You can prevent values not in the AutoComplete list by handling the KeyPress event of the ButtonEdit''s TextBox and validating the input text through the AutoComplete control. this.buttonEdit1.TextBox.KeyPress += new KeyPressEventHandler(this.HandleTextBoxKeyPress); private void HandleTextBoxKeyPress(object sender, KeyPressEventArgs args) { if(Char.IsLetterOrDigit(args.KeyChar)) { string modifiedText = this.buttonEdit1.TextBox.Text.Substring(0, this.buttonEdit1.TextBox.SelectionStart) + args.KeyChar + this.buttonEdit1.TextBox.Text.Substring(this.buttonEdit1.TextBox.SelectionStart+this.buttonEdit1.TextBox.SelectionLength); if(this.autoComplete1.GetMatchesCount(modifiedText) == 0) args.Handled = true; } } Regards, Davis

Loader.
Live Chat Icon For mobile
Up arrow icon