Lock DataGridView Changes

0

I am creating a Windows Forms C # request screen in which the user fills in the order item data and then clicks an "Add" button, which instantiates an OrderItem object, adds it to a list and then assigns this list to the DataSource of a DataGridView. So far so good.

Problems occur when the user clicks on the grid. Although the ReadOnly property is enabled, the AllowUserToAddRows, AllowUserToDeleteRows properties are disabled, and the EditMode property is set to EditProgrammatically, when it receives any click, the grid bursts the error message "The -1 index does not have a value." >

I would like to be able to block changes to this grid, allowing only the user to select rows so that I can delete them through a button that will be implemented later.

Maybe it's an extremely basic thing, but although I've researched a lot on Google, I still have not found any plausible solution, so any help will be greatly appreciated!

Thank you!

    
asked by anonymous 29.03.2017 / 03:52

0 answers