Solved

Databound ComboBox Losing its value on .EndEdit

Posted on 2010-11-29
7
1,055 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
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with LINQ and XML 10 36
Exit the loop 4 43
Write to file when application closes (by logoff) - VB.NET 1 32
How to open form using item in Listbox. 8 21
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

810 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