Solved

combobox displayed text not changing when index changed...

Posted on 2009-05-20
4
555 Views
Last Modified: 2012-05-07
In a winforms program, I have a combobox bound to a list of datasource.   When I change its selectedindex to 0, everything works as expected, except the text displayed in the entry field remains blank.   I can't find anything in the code to account for this:

frm.ComboBoxForms.SelectedIndex = 0

The debugger shows me the datasource is populated,  selectedindex IS 0,  and the list does drop down when the combobox is clicked.
frm.comboboxforms.text shows the correct value in the debugger, but selectedtext remains empty.    if I try programmatically setting the selectedtext equal to the text, selectedtext remains empty, but text displays doubled!

 Is there some property I may be overlooking?  This WAS working fine at one time, I can't figure out what's going on.  Any help greatly appreciated, this is really slowing down my project big time.  Thanks in advance.


0
Comment
Question by:codefinger
  • 2
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
oobayly earned 500 total points
ID: 24431770
SelectedText only returns the actual text highlighted in the ComboBox. ie. If no text is hightlighted, SelectedText will be empty. Try using the Text property instead.

This one a caught me more than once as it's easy to assume that SelectedText works like SelectedIndex, SelectedItem & SelectedValue
0
 

Author Comment

by:codefinger
ID: 24434299
I think we are ALMOST there, but let's say I want to programmatically make the 3rd item in the drop down list be the one that displays to the user beside the drop down arrow.   Right now, just changing the selected index (as in my first example to zero)  does not display ANYTHING next to the arrow.

Thanks again for your (continuing) assistance.

--Al
0
 
LVL 15

Expert Comment

by:oobayly
ID: 24435592
Is the ComboBox showing any of the items when the Drop-down list is shown? My initial thought would have been that the DisplayMember isn't correct, but if the Text value is correct in the debugger and nothing is displayed in the entry field, I can't quite explain.
Any chance you can post the portion of the code doing the databinding?
0
 

Author Closing Comment

by:codefinger
ID: 31583492
You could NEVER have figured this out with what little I gave you to work with, so you earn the points just for trying....would you believe the solution was frm.comboboxforms.selectedvalue = Convert.ToInt32(labeldo.HPFNO) ????     Without the conversion, selectedvalue remains nothing.   Not sure WHY I have to do this conversion, but it works.  Weird.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

937 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

Need Help in Real-Time?

Connect with top rated Experts

4 Experts available now in Live!

Get 1:1 Help Now