[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

combobox displayed text not changing when index changed...

Posted on 2009-05-20
4
Medium Priority
?
564 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
[X]
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
  • 2
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
oobayly earned 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

650 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