StrataFrame Forum

Prevent user from typing in Combobox/ComboBoxEdit...

http://forum.strataframe.net/Topic8982.aspx

By StarkMike - 5/23/2007

My question is about a ComboBoxEdit, which is the SF wrapped version of a DevExpress LookUpEdit, however it would be nice to know the answer to this question for a regular SF Combobox also. ;-)



How can I allow the user to type in a ComboBoxEdit so that it suggests related items as they type but prevent them from typing in something that isnt in the list?
By StrataFrame Team - 5/23/2007

You'll have to override the OnKeyDown method of the control and search do your searching based upon the current text plus the new character.  If a match is found, then narrow your list and allow the OnKeyDown to proceed.  However, if a match is not found, then set the appropriate e.Handled and e.SuppressKeyPress properties on the event args and bail (don't even call the base.OnKeyDown() because you don't want the event to be raised because you don't want to allow the keypress).