Solved

Limit to the list

Posted on 2003-10-23
6
285 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 50 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

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!

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

623 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