Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Limit to the list

Posted on 2003-10-23
6
Medium Priority
?
286 Views
Last Modified: 2010-04-16
Greetings,

I have a ComboBox defined as "DropDown" style. I want to limit the user's input, so the user can only type/pick the item from the drop down list.

Thanks in Advance.
0
Comment
Question by:mrong
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 1

Accepted Solution

by:
jlach earned 150 total points
ID: 9610102
You would want to do this either using the KeyUP event or the TextChanged event ... loop throug the items in the combo box (foreach.... in ....) .. if the strings found, they can type, if not, stop them from typing.. if using keyup.. you can use e.handled = true .. if using textchanged, make sure you keep a variable of the text before the text changed event (KeyDown maybe?) and then set the text back to that variable
0
 

Author Comment

by:mrong
ID: 9611318
Please explain "if the strings found, they can type, if not, stop them from typing". Do you mean check the user's input character by character or the whole string? Please provide more details.
Thanks.
0
 
LVL 1

Expert Comment

by:jlach
ID: 9612596
check the current string typed in the combo box against all items in the combo box, if the string is not found to be contained in any of the items, set the text back to what it was before the keypress
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mrong
ID: 9613973
Hi jlach,

I found a sample code at the following URL and I think it fits my needs. But I am not sure how to put into my code. Could you help me? Thanks.

http://www.thecodeproject.com/cs/combobox/csautocomplete.asp
0
 
LVL 15

Expert Comment

by:SRigney
ID: 9616604
You may be ok with just changing the DropDownStyle to DropDownList.
This prevents typing in new items, and as the user types the list finds the closest item to the typing.
0
 

Author Comment

by:mrong
ID: 9616647
I tried that already. But the current data won't be show up in the ComboBox. Those list Items are there.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question