DataGridView cancel with escapeDataGridView cancel with escape
Old forum URL: forums.lhotka.net/forums/t/5583.aspx
danielmartind posted on Tuesday, October 14, 2008
Hi,
I am using CSLA 3.0.5. I have a object tree with an editable root object with serveral child collections all set up in same way as Resource in the Project Tracker example.
I have bound a collection to a DataGridView and allowed adding by overiding AddNewCore. How do I cancel a new row when the escape key is pressed?
Dan
JoeFallon1 replied on Tuesday, October 14, 2008
1. When Escape is pressed Databinding should take care of removing the new row automatically.
2. If #1 is not working right, then consider upgrading - many databinding fixes were made over time and it is best to be on the latest version. I can't recall the version that Rocky thinks he "finally got it". But even now there are some edge cases that may be an issue. I belivev Rocky recently said that WinForms can't die soon enough with their odd databinding issues. At least WPF is clearer in that regard.
Joe
danielmartind replied on Tuesday, October 14, 2008
Thanks for responding.
#1 is not working and I am using 3.0.5. I don't really want to upgrade to 3.5/6 yet as I am working on .net 2 projects and they need to support Win2000.
It can reproduce it in project tracker by editing ProjectResources to overide AddNewCore and the ProjectEdit control to allow new rows.
It's not a major problem as the user can delete the row by selecting and pressing delete.
Dan
danielmartind replied on Wednesday, October 15, 2008
It works fine in that example but there are differences from my project. I will create another project wich targets 3.0.5 so I can check that too.
The other differences are that I have validation rules and I register the ListChanged event calling OnUnknownPropertyChanged as in the Project Tracker example. Could either of these be causing the trouble?
Dan
RockfordLhotka replied on Wednesday, October 15, 2008
This is why I recommended looking at that particular project.
Windows Forms data binding is very particular about how things
are done. It leaves little room for flexibility. The sample app shows the
correct approach if you want in-place grid editing to work, and you really need
to conform to that model.
ProjectTracker doesn’t use in-place grid editing, and so
doesn’t conform quite as strictly to the hard-core rules imposed by data
binding.
Rocky
danielmartind replied on Thursday, October 16, 2008
It is the ListChanged event of the collection which is causing the problem. What are the consequences of not using this. I am not doing anything in the event handle other than the OnUnknownPropertyChanged() method as PTracker in this instance. Where I do need to make use of that event, is there anything I can change to enable the proper behavour or do I just have to live with it?
Think I might brave 3.6 and wpf for the next project!
Dan
RockfordLhotka replied on Friday, October 17, 2008
You should not need to handle that event, and probably shouldn’t
be calling OnUnknownPropertyChanged() there.
Rocky
danielmartind replied on Monday, October 20, 2008
Thanks for your responses.
I do use that event to calculate totals from child objects in the root object in some cases but will remove from the others. Is this a good way of doing this or is there a better way?
Is the PTracker example include the event just to show how to handle it or is it providing some other function?
Dan
Copyright (c) Marimer LLC