Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ComboBox - Bound to Business Object - Update Question

Status
Not open for further replies.

eb24

Programmer
Dec 17, 2003
240
US
Working on C# 2.0 Windows Forms with an MVC Pattern in place. I have a bunch of ComboBoxes that are bound to Business Object BindingSources, i.e. Collection BO. Everything works perfectly (CRUD) but I just noticed that if the User tries to update one of the ComboBoxes by deleting its value (i.e. a value not in the collection) and tries to save, the old value is kept. The user would like no value populated. I've tried investigating _Validating, _TextChanged, and other Events to see if I could somehow set the value to "", but can't seem to see how. Has anyone resolved a similar issue?
 
Yes but the weekend has come to soon.

I think it was in the textchanged event or selectedindexchanged event and then setting selectedindex to -1 and/or text to ""

I can confirm this after the weekend.

Christiaan Baes
Belgium

My Blog
"In a system where you can define a factor as part of a third factor, you need another layer to check the main layer in case the second layer is not the base unit." - jrbarnett
 
chrissie1:

Thanks for your reply - I was wondering if you will be able to assist me still?
 
eb24, I haven't tried chrissie1's solution, but I believe he is on the right track. I do have a question for you though. You mentioned that you're using an MVC pattern with WinForms. Is there a framework you're using or is it something you've come up with on your own?
 
Well, the framework I'm using has MVC as a basis but has been modified. I am using some of the great templates via If you're using a code generator, I stronly recommend this route. Hope this helps.

Any other input regarding my original question?
 
It should be either the selectedvaluechanged or the textchanged event.

the other option is to get a control that has the "delete" button on it. This is the new style MS has come up with (shudder)

It looks kind of like the control in the middle of this image


If that doesn't work for you, you can always add a "blank/null" record in your datasource before binding.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top