We help IT Professionals succeed at work.
Get Started

Replaced textboxes with comboboxes - now I get "An unhandled exception of type 'System.StackOverflowException' occurred in *****.exe"

TSFLLC asked
Last Modified: 2012-05-11
I have a Windows form that previously contained custom AutoComplete functionality and was tied to about 15 textboxes.  I just finished stripping those textboxes and replacing them with standard unbound comboboxes with AutoComplete turned on.

EVERY time I open the form, access a record or two.  THEN I close and reopen the form.  WHEN I POPULATE EITHER THE FIRST OR SECOND RECORD AGAIN....StackOverflowException.  Until I replaced textboxes with comboboxes, this form has worked for three years.

I don't ever use comboboxes.  So there are several things to note that I may or may not be doing correctly when using VB's combobox.  

1)  With my original autocomplete, I never performed a cmbobox.DataSource = dv, combobox.DisplayMember = "id", cmbobox.ValueMember = "desc" etc. until the textbox was active. Also, my autocomplete used a listbox instead of a combobox.  Now, I create With combobox.DataSource etc. for ALL of these comboboxes on FormLoad.  Is this appropriate or should I do this individually only when each combobox is accessed?

2)  When I populate the form using a dataview I populate the comboboxes with the .SelectedValue and not .Text.  It eleviates having to join all of these tables to my main table in a SQL select.  Is this inappropriate?  Should I set .Text?
Watch Question
Most Valuable Expert 2012
Top Expert 2014
This problem has been solved!
Unlock 1 Answer and 22 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE