Click here to Skip to main content
15,881,812 members
Home / Discussions / Windows Forms
   

Windows Forms

 
GeneralRe: Data Binding to an Object that may be Read Only Pin
Simon Bridge10-Feb-13 10:45
Simon Bridge10-Feb-13 10:45 
GeneralRe: Data Binding to an Object that may be Read Only Pin
Eddy Vluggen12-Feb-13 7:53
professionalEddy Vluggen12-Feb-13 7:53 
GeneralRe: Data Binding to an Object that may be Read Only Pin
Simon Bridge12-Feb-13 10:55
Simon Bridge12-Feb-13 10:55 
BindingSource is an IComponent, the main definition of a component being that it implements IDisposable, - so yes it does have a Dispose method, and this is being correctly invoked by the 'Container' on the form when it gets disposed.


However, I think I have discovered the problem. The issue is the record that is currently on-screen (so it's a data-input form with text-boxes, combo's etc. - not a data-grid)

When you close the form, the record currently on screen, (which was put into edit mode as soon as the record became current) is not removed from edit-mode.

Turns out, there are CancelEdit() and EndEdit() methods on the BindingSource object itself. I trapped the Form.Closing event, and invoked CancelEdit() on the primary binding source for the form, and it now releases all the locks.

I put in some logic to determine if the current record has pending changes, and call EndEdit() instead to keep the changes.

This even works when the binding source has other data sources hanging off it (i.e. when a property of the current object/record is itself a data-source ('cos its a list), - on some forms in my system this can cause upward of 50 records being locked at one time, which was causing lots of headaches when they weren't unlocking)

I am still a little unsure why you have to explicitly call either EndEdit() or CancelEdit() from the binding source - I would have put clean-up code in the Dispose method if I were writing the class. My best guess is that the Begin-End/Cancel edit semantics are more closely coupled with the DataRow and DataGridView components.
GeneralRe: Data Binding to an Object that may be Read Only Pin
Eddy Vluggen12-Feb-13 12:27
professionalEddy Vluggen12-Feb-13 12:27 
QuestionImplement jQuery Tag-it functionality in C# Win Form Pin
Member 29389611-Feb-13 7:47
Member 29389611-Feb-13 7:47 
QuestionRe-write a MS Access application to Visual Studio Pin
Jaap Britz19-Jan-13 23:23
Jaap Britz19-Jan-13 23:23 
AnswerRe: Re-write a MS Access application to Visual Studio Pin
Eddy Vluggen20-Jan-13 2:32
professionalEddy Vluggen20-Jan-13 2:32 
GeneralRe: Re-write a MS Access application to Visual Studio Pin
Maciej Los19-Mar-13 7:01
mveMaciej Los19-Mar-13 7:01 
AnswerRe: Re-write a MS Access application to Visual Studio Pin
Maciej Los19-Mar-13 7:05
mveMaciej Los19-Mar-13 7:05 
QuestionHow to Deploy my application along with database Pin
Nag4dotnet31-Dec-12 0:27
Nag4dotnet31-Dec-12 0:27 
AnswerRe: How to Deploy my application along with database Pin
savbace10-Jan-13 22:54
savbace10-Jan-13 22:54 
QuestionWindows Form Designer code and importing old projects Pin
Aaron Hartley28-Dec-12 10:42
Aaron Hartley28-Dec-12 10:42 
AnswerRe: Windows Form Designer code and importing old projects Pin
Mike Meinz21-Jan-13 8:44
Mike Meinz21-Jan-13 8:44 
Questionparent/child bindingsource save on new row does not work Pin
PrissySC8-Dec-12 11:07
PrissySC8-Dec-12 11:07 
AnswerRe: parent/child bindingsource save on new row does not work Pin
PrissySC10-Dec-12 3:36
PrissySC10-Dec-12 3:36 
QuestionDetect if ANY control is clicked inside a form, regardless of the container Pin
Dennis Bork3-Dec-12 3:39
Dennis Bork3-Dec-12 3:39 
Answercrosspost from C# forum Pin
Eddy Vluggen3-Dec-12 4:47
professionalEddy Vluggen3-Dec-12 4:47 
GeneralRe: crosspost from C# forum Pin
Pete O'Hanlon3-Dec-12 4:54
mvePete O'Hanlon3-Dec-12 4:54 
GeneralRe: crosspost from C# forum Pin
Eddy Vluggen3-Dec-12 4:56
professionalEddy Vluggen3-Dec-12 4:56 
AnswerRe: Detect if ANY control is clicked inside a form, regardless of the container Pin
Eddy Vluggen3-Dec-12 5:03
professionalEddy Vluggen3-Dec-12 5:03 
AnswerRe: Detect if ANY control is clicked inside a form, regardless of the container Pin
April Fans27-Dec-12 16:13
April Fans27-Dec-12 16:13 
AnswerRe: Detect if ANY control is clicked inside a form, regardless of the container Pin
jenitshah19-Jan-13 15:59
jenitshah19-Jan-13 15:59 
AnswerRe: Detect if ANY control is clicked inside a form, regardless of the container Pin
Simon Bridge4-Feb-13 12:13
Simon Bridge4-Feb-13 12:13 
QuestionWix based installer does not execute custom action on upgrade Pin
Prasanth Vijayan11-Nov-12 23:12
Prasanth Vijayan11-Nov-12 23:12 
Questionhow to ad a new records into database using data binding? Pin
tinychi26-Oct-12 23:42
tinychi26-Oct-12 23:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.