Also, the drop down list will add / remove handlers so you can easily test out which handlers do what without having to specifically comment out lines of code.
I want to refactor this code that is currently in a partial Form Class and deals with edits made on certain cells in a datagridview (in this case called dgv Replenish).
So, we've gotten all of the from outside of the form and injected it in. Well, we'll add some to the interface for the presenter to respond to. It catches the raised event, and interacts with the View's interface, performing this work.
This means, that you can now relatively simply test your code. Moq makes it easy to mock out the view and test the presenter. Your Form (IParts View) needs to be with this pattern before trying to refactor to it with this monolithic code behind that you have there.
Any solution is going to involve using an event that definitely will fire to stop the Data Grid View from thinking it’s in edit mode.
This problem was also raised in a Stack Overflow Question which seemed to advocate for handling the method, thereby ensuring that the grid would evaluate whether or not the Cell’s value had, indeed, changed and fire the corresponding event appropriately I must admit, this works, but feels like more of a work around than a solution.
I would like to refactor so that I can create unit tests to be able to test the logic that effects changing the back color of cells, and updating other cells.
The problem I am having is how to refactor logic to an external class, that has references to the winform controls.
After looking into the problem at some length, MSDN actually seems to offer the best solution right on their Cell Content Click event page. I like that it tells us very specifically what has happened to the grid at the point in time when the event is raised and handled.What if someone is able to make a selection without a click event?There seems to be a non-zero percent chance that this might fire incorrectly in some unforeseen situation.This helps identify when, and in what order, events are being handled without explicitly having to set breakpoints and wait for the code to catch each event.In the options group box, you can choose to include event handlers notifications or not.