add button in Datagrid

  • Thread starter Thread starter Grey
  • Start date Start date
G

Grey

I need to add DELETE button in each row of the datagrid. When user click the
button, the row will be deleted out and the beneath rows will be shift up
automatically. Is it possible to do that ?? IF so, how to ??
 
Grey,

Assuming that this is a Windows Forms data grid, then you will have to
create a new class which derives from DataGridColumnStyle. In it, you would
render your button, and set up the event handlers for when the button is
clicked. Of course, you would have to modify all the data bound to the grid
to include an extra column. This is required because there needs to be
something to bind to so that the button displays.

Once you have that set up, you should be able to work to the data source
and delete the row you are on (or at least find out which row is clicked,
and access the data binding and delete the record).

Hope this helps.
 
Back
Top