Let's find out; does the thing implement IDisposable? Add it if not, override if it does, and use the method to write a message to the VS-output.
Simon Bridge wrote:
the BindingSource component, doesn't always call IEditableObject.EndEdit() or IEditableObject.CancelEdit() for every item it has called IEditableObject.BeginEdit() on.... this seems like a fairly dramatic design flaw in this component.
Soo, it still had focus when being removed from the form? The user didn't cancel his edit-mode, move focus to end editing? What happens if you manually focus something else, like a dead button, before removing it from the form?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
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.
I would liketo implement a functionality similar to jQuery TagIt into C# windows forms. Here is the link for jQuery - http://aehlke.github.com/tag-it/
I am thinking of creating a user control for this functionality.
Any help on how togo about this?
How to deploy a windows application along with mdf file. Here when i install application in client pc. It should maintain database without sql server. I have mdf file of my database. How can i deploy it. I want to deploy as standalone application. Please some one help me to deploy. Step by Step.
If you want to deploy a standalone application and database also it would be better to use an embedded database. For example: SQLite or SQL Server Compact Edition. In this case database engine is represented by set of assemblies. So you can easy deploy them and database file with your app.
I've recently brought an old PPC (PocketPC) 2003 project developed in VS 2003 into VS 2008. This converted project has some issues with it so as an alternative to conversion I created a new project a brought the code and forms from the old project, otherwise identical to the original.
One problem is that I'm running into with both the old original and new projects is that if I change a form in any way and then save a new error is flagged by VS: "Constant cannot be the target of an assignment." The error is the same in every form: code generated by the Windows Form Designer, the line that sets name of the form.
Me.Name = "[formname]"
([formname] depends on the form, is something like frmAvailableMaterial, etc). If I delete this line of code the error disappears but the next the time I change the same form, Windows Form Designer again adds the line Me.Name = "[formname]" and is flagged as an error. So the problem keeps reappearing on forms that I have already "fixed". VS 2008 keeps putting back a line that it flags as an error.
For comparison, I looked at a "clean" VS 2008 project that had no forms imported from a VS 2003 project, only forms created within VS 2008. The VS 2008 forms do not show any code generated by Windows Form Designer within the IDE. This form code isn't directly visible to the developer, only indirectly via the form editor. The VS 2003 forms still have this Windows Form Designer code even when brought into VS 2008. Since VS 2008 is having an issue with this form code, it would be ideal if VS 2008 could convert the VS 2003 form to where it would be fully compatible with VS 2008, to where there would be no real functional difference between an imported VS 2003 form and a form created in VS 2008.
Currently, the only work-around that I can think of would be to create new forms within VS 2008 and copy/paste controls and code and manually rewrite events. I'm certain that this would work with the downside being that this would also be a big investment of time and labor. I would like to see if there is an alternative way that permanently fixes this problem but doesn't require a complete reworking of the project. Does anyone know of a way to accomplish this?
You can probably duplicate this error yourself by importing a PPC VS 2003 project into VS 2008 (perhaps it doesn't even need to be PPC).
Parent = context.table
child = From t in parent where ...
In properties, the datasource is set to parent as well.
The bindingnavigators.bindingsource are set to child, all controls and datagrids are bound to the child bindingsoure.
Add new will instaniate a new row. It displays in the datagrids; however, it will not save. The primary key field maintains 0. As soon as I sort or call a new query the row is gone. On reload the row is gone.
I have tried ending edit in reverse order and not reseting the current item (needed to update the changes, which works correctly for some strange crazy reason). The problem exists solely with saving a new row.
Does it make a difference that there are two binding navigators? Due to space and design, I opted for 2, but I have tried the addnew on the second.
Hmmm ... Ideas? (Asked in VB too. Saw the forms forum after.)
Actually, I solved this in quite an odd manner. I added a textbox for the primary key that was linked (bound) to the parent datasource. This solved the add new.
Why the child could not aquire a key value is beyond me. I simply hid the textbox by placing it behind another control. Oh, that reminds me. You cannot set the visibility to false and the key still add. Again, another thing that eludes me entirely. What does visibility have to do with it? I could not find any documentation that linked the visible status to the enabled status, but ah well. Problem was solved.
Hey all, is there a way to detect if ANY control is clicked inside a form? The MouseUp, -Down and so on events can only be set for the form itself, but as far as I have tested i out not for any controls that reside inside it - true? Is there another way? Cheers, Dennis
The MouseUp, -Down and so on events can only be set for the form itself, but as far as I have tested i out not for any controls that reside inside it - true? Is there another way?
False, anything that inherits from Control[^]. See Richards'[^] answer for a recursive method that loops all controls, and hook 'em up to a single event-handler. The 'sender' argument would tell you what control was clicked.
I have an installer developed in Wix. I want to execute one batch command during the upgrade operation. I added one Wix custom action in wxs file. Anybody know to which sequce should i add this for my requirement.