Delete allowed even when datagrid is set to readonly!

G

Guest

I have a datagrid bound to a strongly typed dataset. The datagrid can be made
readonly by either setting its ReadOnly property to True or by setting the
dataset's DefaultView's AllowDelete, AllowEdit, and AllowNew properties to
False. But in either case the datagrid still accepts a delete keypress (i.e.
press the delete key on the keyboard) and while this doesn't actually delete
the record it does set the dataset's HasChanges property to True thereby
causing my code to incorrectly ask the user to save his changes. Can this
problem be fixed?
 
C

ClayB [Syncfusion]

You might be able to avoid this by deriving the DataGrid and overriding its
PreProcessMeesage method, and eating the Delete at that point. Here is a FAQ
link that has sample code doing something similar. It shows how to delete a
confirmation prompt on pressing delete, but you could just return true
without showing a message if the key is delete.

George Shepherd's Windows Forms FAQ contains an entry entitled:

How can I put up a confirmation question when the user tries to delete
a row in the datagrid by clicking on the row header and pressing the Delete
key?

Check it out at:
http://www.syncfusion.com/faq/winforms/search/889.asp

=============================================
Clay Burch, .NET MVP

Syncfusion, Inc.
visit http://www.syncfusion.com for .NET Essentials
 
G

Guest

Cool, I can do this. You've not said I've done something stupid, and the
solution isn't as straight-forward as setting the "NoThisIsReallyReadOnly"
property so does this mean that this is a bug? And if so how does it get
reported and therefore fixed?
 
J

Jeffrey Tan[MSFT]

Hi Richard,

Thanks for your feedback.

Yes, I have reproduced out this issue, it seems it is a limitation of our
product, I will help you to forward this issue to our product team. Anyway,
now, we may workaround it through intercepting the Delete key press at
DataGrid level.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top