Combo box resets to initial value

Combo box resets to initial value

Old forum URL: forums.lhotka.net/forums/t/3624.aspx


rayc posted on Sunday, September 30, 2007

Hello, newbie CSLA here.

I have a datagridview that has a datagridviewcombobox column. I fill this combo box using NameValueListBase. The problem I'm having is that when I run the application, and then change the item in the combo box (modify a value), the value goes back to the original value when I leave the cell. I"m able to modify the other columns. Any help would be greatly appreciated.

 

Ray

jhw replied on Sunday, September 30, 2007

Are you manually entering in a value or selecting a value from the nvl? As you are databound to the nvl, I would think you are going to have to choose from the list.

Heath

rayc replied on Sunday, November 04, 2007

When I open the form, the datagrid view shows the correct values in the datagridviewcombobox column for all the records.  But then, I want to modify the value from one of the records in the datagridviewcombobox column, say the first record. The item that I selected changes back to the original item when I tab to the next field (column) in the datagridview, or when I click in another field in the datagridview.

Yes, I select an item from the combobox.

 

JoeFallon1 replied on Monday, November 05, 2007

Be sure you only bind the NVL once.

Not on every postback! Otherwise you keep re-setting the value.

Joe

rayc replied on Wednesday, November 07, 2007

This isn't a web form, it's a Windows Forms application.
That's what I find strange.

I have a Windows form with a DataGridView which has a combobox column. It's this column that is giving me a problem. When I change the value, it resets when I tab out or when I click to another field. What causes it combo box to rest?

Thanks

 

 

praevsky replied on Friday, January 04, 2008

I've had this problem, and it's perplexing.  The last time, a combobox on one form worked, while another didn't.  I examined both and assured myself that they were configured correctly and similarly.  I'd change one combobox, tab off, and it would change back.  Finally, I decided to strip everything away.  One thing at a time.
First I removed the readWriteAuthorization, bindingSourceRefresh, and errorProvider.
I found that I could now tab off, without the value changing back.  But saving didn't save.
So, I deleted the combobox, changed the field in the datasource to a textbox, and dragged it on.
Progress.  The key displayed, like I expected, and what's more, it saved.
Here's the perplexing part.
I deleted the textbox, changed the field in the datasource to a combobox, and dragged it on.
I changed the Databindings, Advanced, Text to none, and configured the combobox using the 'smart panel'.  I checked Use Data Bound Items, and set the Data Source, Display Member, Value Member, and Selected Value appropriately.  And it worked.
I put the readWriteAuthorization, bindingSourceRefresh, and errorProvider back, and now my form is identical to the original form, which didn't work.
Go figure.

Jimbo replied on Saturday, January 05, 2008

Just don't use the designer to configure you grids and populate the combos ... get used to doing it programatically.

jimbo

Jimbo replied on Saturday, January 05, 2008

I should have mentioned that the BindingSourserefresh control (mentioned in the previous response) is not relevant for datagridviews as it only applies to simple controls.

jimbo

Jimbo replied on Saturday, January 05, 2008

Of course if ravc is not using a BindingSourceControl  then that could be the root of the problem.

jimbo

so24wo replied on Sunday, January 06, 2008

2 rayc:

To find a bag your Form.cs and Form.Designer.cs files are required.

2 praevsky:

Intresting. Can you show all four source files?
Both old Form.cs and Form.Designer.cs which didn't work and new two.

Or you can just compare them youself and say to us are there any differencies.

 

Copyright (c) Marimer LLC