Home > Articles > Programming > Windows Programming

  • Print
  • + Share This
This chapter is from the book

Controlling Modifications to Data in the Grid

The DataGridView control gives you explicit control over whether users can edit, delete, or add rows in the grid. After the grid has been populated with data, the user can interact with the data presented in the grid in a number of ways, as discussed earlier. By default, those interactions include editing the contents of cells (fields) in a row, selecting a row and deleting it with the Delete keyboard key, or adding a new row using an empty row that displays as the last row in the grid.

If you want to disallow any of these interactions, set the AllowUserToAddRows or AllowUserToDeleteRows properties to false, or set the ReadOnly property to true for adding, deleting, or editing, respectively. Each of these properties also raise corresponding XXXChanged property changed events whenever their values are set. When you support adding, editing, or deleting, you may need to handle certain additional events to accept new values for unbound rows or for virtual mode, as described later in this chapter.

  • + Share This
  • 🔖 Save To Your Account