Solved

combobox displayed text not changing when index changed...

Posted on 2009-05-20
4
554 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 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

19 Experts available now in Live!

Get 1:1 Help Now