Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


VB.net ComboBox - DropDownList

Posted on 2013-06-05
Medium Priority
Last Modified: 2013-06-05

I have a ComboBox on my windows form where I use the following code to change the text
          Me.CategoryType1_ComboBox.SelectedText = oResult

I have just changed the DropDownStyle to "DropDownList " and that code doesn't work
Question by:Murray Brown
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
  • 4
  • 3
  • 2
LVL 42

Expert Comment

by:Meir Rivkin
ID: 39222306
DropDownList changes the combobox to be readonly so user cannot change/edit the text of the combobox items.
LVL 10

Expert Comment

ID: 39222309
if you wish to edit the combox text, the property to use is ".text", not selectedtext, selectedtext is readonly.

Author Comment

by:Murray Brown
ID: 39222345
Thanks Sedgwick. Does that mean that I cannot assign a selected item. How would I get around this? Maybe my code should change the DropDownStyle to DropDown, then assign a value then change it back to DropDownList.
Or is this not going to work? Can a selection only be done manually
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 10

Expert Comment

ID: 39222398
You can't. Once it is dropdownlist, you can't change the text. Usually this property is used when the programmer needs to limit the possible values in this dropdown, there shouldn't be any value out of the selection list.
LVL 42

Expert Comment

by:Meir Rivkin
ID: 39222409
thats not entirely correct.

To assign selected item u can either use .SelectedIndex property or use .Text.
when u use ,Text only tsring that is one of the items in the comboxbo is allowed.
any other string u set would not be displayed.
LVL 10

Expert Comment

ID: 39222412
Since you are going to programmatically changing the text, you might want to consider adding an invisible textbox at the same location of the combobox. So when you need to change you change the text in the textbox and make the combobox invisible.

Hope I don't need to guide you which value to use in both situations.
LVL 42

Accepted Solution

Meir Rivkin earned 1000 total points
ID: 39222426

To sum up, to set the text in DropDownList mode, you can use .Text property only.
make sure the text u assign is one of the combobox items, otherwise, blank item will be displayed.
an alternative is to use .SelectedIndex property, which requires u to know the text index in the comboxbox.
LVL 10

Assisted Solution

adriankohws earned 1000 total points
ID: 39222565
Yes, sedgwick is right. Maybe can also try before you change the text, you add that text value into the combobox list of selection, then changing to it shouldn't be a problem.

Author Closing Comment

by:Murray Brown
ID: 39224635
Thank you both for the help

Featured Post

Industry Leaders: 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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

604 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