Information générale
Catégorie:
The Mere Mortals .NET Framework
Titre:
WinForms DataGrid delete
This may be a .NET question more than a MM.NET question, but thought I'd check...
Is there any way, in a WinForms DataGrid, to prevent the user from selecting and deleting rows? Even if I make my DataGrid non-editable (ReadOnly=True), the user can still select one or more rows, press the Delete key, and cause the rows to disappear from view. This doesn't actually do anything in the database, of course, but it's still confusing to the user.
Similarly, in my editable DataGrids, I'd prefer to disable the built-in select-and-delete functionality, and require users to click a Delete button to delete a row. This would prevent deleting multiple rows at once, which I'd like to prevent in some cases.
In the past, I've subclassed the DataGrid and overridden OnCurrentCellChanged to prevent multi-select (by manually de-selecting all but the current row), and ProcessCmdKey to catch the Delete key and Ctrl-A for select-all-rows. This worked (except for catching multi-select with the mouse), but it seemed unnecessarily grizzly.
Does MM.NET offer any alternatives, or is the MM.NET philosophy to have users use the built-in select-and-delete functionality in WinForms DataGrids?
Thanks,
Ric
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement