Solved

Databound ComboBox Losing its value on .EndEdit

Posted on 2010-11-29
7
1,043 Views
Last Modified: 2012-08-14
I have a databound combobox that works just fine when I select any of it's values with the mouse.  The SelectedIndex value returns a 1 before and after the bindingsource.EndEdit.  However, if a user tabs into the combobox and uses the down arrow to select the first value in the combobox, the SelectedIndex value is 1 before the bindingsource.endedit and a zero after the .EndEdit ... Whats this means is that the combobox will not save the value during a new record add.  Please tell me what might be the problem here.
0
Comment
Question by:MrFantastic6
7 Comments
 
LVL 17

Expert Comment

by:Zhaolai
ID: 34236261
The SelectedIndex for the first value in the combobox is 0, not 1.
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 34238088
Add an event handler for the SelectedIndexChanged and see if it fires when the value is changed with arrow key.
0
 
LVL 8

Expert Comment

by:edemcs
ID: 34239003
Make sure you're not doing a postback when leaving the list.  If you're in an updatePanel, you may be unknowingly posting back to the server and the default is being reset to one.

I've had cases where I was explicitly setting the default value somewhere in my code, a postback would occur, and the default value would be reset.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 2

Author Comment

by:MrFantastic6
ID: 34239519
Sorry I meant to specify that I'm using vb .net 2008 windows forms.
0
 
LVL 2

Author Comment

by:MrFantastic6
ID: 34239551
The selectedIndexChanged is firing.  The text value is also pointing to the correct value.  The first entry in the combobox is a blank value which is the zero selectedindex.  The 2nd value in the dropdown is index 1 and the text changes to "Widget".  When I hit the save button, everything is working great until the bindingsource.EndEdit gets fired.  The selectedIndex reverts to 0 and the text in the combobox also reverts to blank.  Now if you use the mouse to make all the selections, everything works just fine.  Very bizarre stuff.
0
 
LVL 8

Expert Comment

by:edemcs
ID: 34241003
Look into the stack trace window while stepping through and verify that the mouse isn't being handled while the key is not.
0
 
LVL 8

Expert Comment

by:edemcs
ID: 34241032
I'd take a look if you provide the code...
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
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…

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

18 Experts available now in Live!

Get 1:1 Help Now