I have 2 issues:rolleyes: :

1. I'm creating a combobox from inside code (sort of dynamic, when the user finishes a row, another row appears) and I would like to know how to set the list of items the user chooses from.

2. How can I block the user from typing custom values into a combobox, but still accept when they select an item from the list?

Thanks;)

Recommended Answers

All 3 Replies

I have 2 issues:rolleyes: :

1. I'm creating a combobox from inside code (sort of dynamic, when the user finishes a row, another row appears) and I would like to know how to set the list of items the user chooses from.

is it possible to see a snippet of what you are doing?

are you stating that if they do something in A then a new combo box is created dynamically on the form at point B and you need to know how to modify it?

but the easiest way to add data to a combo box is by setting the range of items to choose from

_MyComboBox.Items.AddRange( new string[] {
"ITEM 1",
"ITEM 2",
"ITEM 3",
"ITEM 4",
....
"ITEM 10" } );

2. How can I block the user from typing custom values into a combobox, but still accept when they select an item from the list?

Thanks;)

change the combobox to a dropdownlist in the dropdownstyle combo box settings and the user cannot enter a string in anymore, just select from the list.

Thanks for answer to question two. I figured out the first one though.

Thanks for answer to question two. I figured out the first one though.

glad i could help out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.