Combo Box Control

  • Thread starter Thread starter C#Newbie
  • Start date Start date
C

C#Newbie

So here is my problem, I have a program that i would like to have some
control similar to a combo box. However, I don't want it to be
editable. How can I do this? Also, when my server pass information to
me, i would like to reflect that information in that combo box; in
other words, the information is already in the combo box, i just want
that information showing and highlighted. Is there anyway to do this?
 
You can make the combo read only by setting the dropdown style to
dropdownlist.

To make it show the item you want you need to use the items collection.


ComboBox.ObjectCollection oc = comboBox1.Items;

iterate through the object collection (youll have to cast to the
required type)

foreach (object o in oc)
{
if ((o as string).CompareTo("mystring") == 0)
{
comboBox1.SelectedItem = o;
}
}

and when you find the item you want set this as the selected item

comboBox1.selectedItem = o;

Hope this helps
 
seems like it will work, i will check tomorrow since i need to connect
through to the server. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top