I am trying to implement a simple Windows forms application where a user can edit instances of a simple Person class. The application uses the standard propertygrid, assigning the SelectedObject property of the grid property to instances of the Person class. When the user clicks the Save menu item, the application retrieves the selected item from the property and saves it. It works great.
However, if a shortcut is used to save the SelectedObject property of the gridgrid, such as ctrl + S assigned to the menu item, no changes are accepted. It seems that this is due to the fact that the properties of the Person object are not updated if the field in the grid properties does not lose focus and ctrl + S shortcut does not remove the focus from the fields in the properties.
Other developers, such as Mark Gilbert, solved this problem by displacing focus from the Grid property, but this seemed to hack a bit, especially since it would be nice to keep focus on the field. Obviously, the developers of Visual Studio understood this, but I did not understand how to do this.
source
share