DataGridView addingnew but no data
-
I have a strange little problem with a bound datgridview. The DGV is on an unbound form but is itself bound to a bindingsource which is in turn bound to a bindinglist(of T) which encapsulates a list of business objects (with me so far.) Ok so when the user clicks an empty row in the DGV the addingnew event is fired immediately - kind of odd behaviour that I thought. The user then types some text into the new rows first field. When I check the contents of the bindinglist a new object has indeed been added but does not contain the text that was typed; in short it is completely blank. If you then reload the form move to the blank row added previously and enter the text again then the empty object in the binding list is correctly updated. I hope you have all been able to follow this explanation and I hope even more that someone can explain what is going on.
http://www.ViSYNERGY.com End of Line.
-
I have a strange little problem with a bound datgridview. The DGV is on an unbound form but is itself bound to a bindingsource which is in turn bound to a bindinglist(of T) which encapsulates a list of business objects (with me so far.) Ok so when the user clicks an empty row in the DGV the addingnew event is fired immediately - kind of odd behaviour that I thought. The user then types some text into the new rows first field. When I check the contents of the bindinglist a new object has indeed been added but does not contain the text that was typed; in short it is completely blank. If you then reload the form move to the blank row added previously and enter the text again then the empty object in the binding list is correctly updated. I hope you have all been able to follow this explanation and I hope even more that someone can explain what is going on.
http://www.ViSYNERGY.com End of Line.
Actually I have now solved this - at about two in the morning, I worked it out. Calling endedit on the bindingsource component doesn't (for reasons best known to MS,) pass through to the DGV that's bound to it. So to make my code work correctly I have to call endEdit on the DGV first and then call endEdit on the bindingsource. I call this very strange behaviour, but at least now I can move on.
http://www.ViSYNERGY.com End of Line.