473,486 Members | 2,424 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Combo Box interaction

16 New Member
I have a combo box that I've hard coded Yes No into the 'Items...(Collection)' area. However, users are able to input anything into the combo box and my code breaks when saving. Is there a property that I can set that will allow users to choose Yes or No, but not allow them to enter anything?

Thanks
Mike
May 28 '09 #1
2 1314
PRR
750 Recognized Expert Contributor
Could you post some sample code? You could have default selection...
Expand|Select|Wrap|Line Numbers
  1.  comboBox1.SelectedIndex = 0;
  2.  
Are you adding items to the combo box?
May 28 '09 #2
tlhintoq
3,525 Recognized Expert Specialist
Go to the properties of the combobox.
Change the "DropDownStyle" from "DropDown" to "DropDownList".
This style does not allow user input.

TIP: Get used to the idea that if a user can find a way to break your code THEY WILL. Put in more error correction for just about everything.

Instead of
Expand|Select|Wrap|Line Numbers
  1. if (Answer == "Yes") DoMethodA();
  2. else DoMethodB();
  3.  
Maybe something a little more robust
Expand|Select|Wrap|Line Numbers
  1. switch (Answer.ToLower())
  2. {
  3. case "yes"
  4. DoMethodA();
  5. break;
  6.  
  7. case "no"
  8. DoMethodB();
  9. break;
  10.  
  11. default
  12. DoErrorMessage();
  13. break;
  14. }
  15.  
May 28 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
4108
by: Aaron Queenan | last post by:
I have a form which performs some asynchronous code. I want to display a wait cursor when it starts, and hide the wait cursor when it has completed. This part works fairly well, using: ...
17
14778
by: Aussie Rules | last post by:
Hi, I want to have a single line combo box dropdown, but where i can selected multiple items in the drop down via a check box... I can see one in the standard tool box... is there one ? If...
2
6876
by: deko | last post by:
When to use a privileged user thread rather than a windows service? That's the question raised in a previous post . It was suggested that if the service needs to interact with a WinForms app...
4
21827
by: vivek | last post by:
I am new to flash and want someone to guide me, Is it possible to create a UI entirely in Flash and that will inetract with C# components (backend) and these components will in return interact...
12
12101
by: Doogie | last post by:
How do I make a value the default value for a combo box in ASP 3.0? What I have below does NOT work, yet I've seen it in HTML file examples before (and works if I put it in a HTML file by itself,...
9
2909
by: prakashwadhwani | last post by:
I have an unbound combo box in the form header. I have used an input mask "CCCC" 40 times to limit the max number of characters to 40. When I tab into the combo box & press a character say "K"...
0
2115
by: Omar Abid | last post by:
Reason of this project: The Microsoft.VisualBasic.Interaction class exposes many useful commands and methods that were available in Visual Basic like AppActivate, Beep, Callbyname... This...
3
3927
by: mmm | last post by:
I am looking for advice on Python Editors and IDEs I have read other posts and threads on the subject and my two questions at this time are mainly about the IDLE-like F5-run facilities. While I...
0
7100
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7126
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6842
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3070
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.