CHAPTER 22 ADO.NET PART II: THE DISCONNECTED LAYER
Figure 22-6. Binding a DataTable to a Windows Forms DataGridView
Deleting Rows from a DataTable
Now, assume you would like to update your graphical interface to allow the user to delete a row from the
in-memory DataTable that is bound to the DataGridView. One approach is to call the Delete() method of
the DataRow object that represents the row to terminate. In this case, you specify the index (or DataRow
object) representing the row to remove. To allow the user to specify which row to delete, add a TextBox
(named txtCarToRemove) and a Button control (named btnRemoveCar) to the current designer. Figure 22-7
shows one possible UI update (note this example wraps the two controls in a GroupBox control,
illustrating how they are related).
881